O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Our Service Integration Test

We’ll use the Twitter gem to interface with Twitter.[21] We’ll put that in the Gemfile. We’re also going to need the VCR and Webmock gems in our test environment:

 
gem ​'twitter'
 
gem ​'vcr'​, group: :test
 
gem ​'webmock'​, group: :test

We’ll also have to reinstall the bundle with bundle install.

We need a Twitter API key and secret key. In Rails 4, those get placed in the secrets.yml file, which typically is not stored in your code repository, though I’ve put it in our sample code for ease of setup:

external/01/gatherer/config/secrets.yml
 
development:
 
secret_key_base: ​|
 
9cbb1cdd81bd1e79999d8f91ec57b0ced0e59ec961f9af56e77a5e514acf7cc9f646e83aedd
 
5293f44685c47e717eade8677fca153d9c65ffb441d4fdff33052

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required