Adapter Tests
The adapter tests work between the adapter and the server, using VCR as a medium:
| require "rails_helper" |
| |
| describe AvatarAdapter do |
| |
| it "accurately receives image url", :vcr do |
| user = instance_double(User, 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 is shown passing in a double rather than an actual User instance. Using a VCR cassette, you create a new adapter and assert that the adapter provides the expected URL when queried. The test also doesn’t have a particular ...
Get Rails 5 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.