Skip to content

Instantly share code, notes, and snippets.

@cflipse
Forked from levycarneiro/tweet_spec.rb
Created March 13, 2009 14:10
Show Gist options
  • Save cflipse/78570 to your computer and use it in GitHub Desktop.
Save cflipse/78570 to your computer and use it in GitHub Desktop.
describe Tweet do
describe "basic fetching of tweets" do
describe "(search conditions)" do
attr_reader :new_search
before do
@new_search = mock(Twitter::Search, :null_object => true)
Twitter::Search.should_receive(:new).and_return(new_search)
end
after do
Tweet.fetch_new_tweets
end
it "should search for tweets containing 'protip:'" do
new_search.should_receive(:containing).with('protip:').and_return(new_search)
end
it "should only find new tweets" do
last_id_processed = Tweet.stub!(:last_id_processed => 123)
new_search.should_receive(:since).with(123).and_return(new_search)
end
it "should skip retweets" do
new_search.should_receive(:not_retweeted).and_return(new_search)
end
it "should end with a fetch" do
new_search.should_receive(:fetch) # returns nil, if anything chains off this, boom!
end
it "should happen in a certain order" do
new_search.should_receive(:containing).ordered.and_return(new_search)
new_search.should_receive(:not_retweeted).ordered.and_return(new_search)
new_search.should_receive(:since).ordered.and_return(new_search)
new_search.should_receive(:fetch).ordered
end
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