Skip to content

Instantly share code, notes, and snippets.

@thiagoa
Last active October 10, 2016 16:32
Show Gist options
  • Save thiagoa/149adb5528d3b28de40a2f05b5f9aace to your computer and use it in GitHub Desktop.
Save thiagoa/149adb5528d3b28de40a2f05b5f9aace to your computer and use it in GitHub Desktop.
First version of twitter timeline hub spec
# spec/models/twitter_timeline_hub_spec.rb
require 'spec_helper'
require 'twitter'
require_relative '../../app/models/twitter_timeline_hub'
RSpec.describe TwitterTimelineHub do
describe '#call' do
it 'collaborates with twitter_client to get a timeline and delivers a result struct' do
twitter_client = instance_double(Twitter::REST::Client)
allow(twitter_client).to receive(:user_timeline).and_return([])
twitter_hub = TwitterTimelineHub.new(twitter_client)
result = twitter_hub.call('screen_name', count: 5)
expect(result).to have_attributes(status: :ok, tweets: [])
expect(twitter_client).to have_received(:user_timeline)
.with('screen_name', count: 5)
.once
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment