Ruby on Rails Flashcards
1
Q
Using a web API
A
- Construct a URI request using URI class.
- Issue the request using Net::HTTP
- Parse the XML response
2
Q
RSpec specfile example
A
require ‘spec_helper’
describe MovieController do describe 'searching TMDb' do ... end end
3
Q
Testing a spec file
A
- Manually type ‘rspec spec/controllers/xxx_controller_spec.rb’
- Use ‘autotest’ tool: Once you type ‘autotest’, then whenever you update a file, the RSpec will update the test results.
4
Q
Setting up RSpec
A
- The following two lines must be added in Gemfile
gem ‘ZenTest’
gem ‘rspec-rails’ - Type ‘bundle install’ as usual.
- Before using Rspec, you must do ‘rails generate rspec:install’. This is just a one-time thing, and will generate the necessary directories/files.