Adapter Tests

The adapter tests work between the adapter and the server, using VCR as a medium:

external/02/gatherer/spec/models/avatar_adapter_spec.rb
​ 
require ​'rails_helper'​
​ 
​ 
describe AvatarAdapter ​do​
​ 
it ​"accurately receives image url"​, :vcr ​do​
​ 
user = double(twitter_handle: ​"noelrap"​)
​ 
adapter = AvatarAdapter.new(user)
​ 
url = ​"http://pbs.twimg.com/profile_images/40008602/head_shot_bigger.jpg"​
​ 
expect(adapter.image_url).to eq(url)
​ 
​end​
​ 
​end​

This test has no dependency on the client, which we show by passing in a double rather than an actual User instance. Using a VCR cassette, we create a new adapter and assert that the adapter provides the expected URL when ...

Get Rails 4 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.