Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
describe Tweet do
describe "basic fetching of tweets" do
it "should fetch new tweets from Twitter" do
new_search = mock(Twitter::Search)
search_containing = mock(Twitter::Search)
search_not_retweeted = mock(Twitter::Search)
search_since = mock(Twitter::Search)
last_id_processed = Tweet.stub!(:last_id_processed => 123)
search_since = mock(Twitter::Search)
Twitter::Search.should_receive(:new).and_return(new_search)
new_search.should_receive(:containing).with('protip:').and_return(search_containing)
search_containing.should_receive(:not_retweeted).and_return(search_not_retweeted)
search_not_retweeted.should_receive(:since).with(123).and_return(search_since)
search_since.should_receive(:fetch)
Tweet.fetch_new_tweets
end
it "should get the last tweet_id processed from the database" do
last_tweet = mock(Tweet)
Tweet.should_receive(:last).and_return(last_tweet)
last_tweet.should_receive(:object_id)
Tweet.last_id_processed
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment