-
-
Save cflipse/78570 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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