From faf26e61a52fedf67d339db663eb9f49451bb3bd Mon Sep 17 00:00:00 2001 From: Steve Agalloco Date: Thu, 8 Dec 2011 01:06:07 -0500 Subject: [PATCH] some test refactoring --- spec/tweetstream/client_spec.rb | 104 +++++++++++++++++--------------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/spec/tweetstream/client_spec.rb b/spec/tweetstream/client_spec.rb index b024533..a4f8d6f 100644 --- a/spec/tweetstream/client_spec.rb +++ b/spec/tweetstream/client_spec.rb @@ -253,38 +253,61 @@ end end - it '#track should make a call to start with "statuses/filter" and a track query parameter' do - @client.should_receive(:start).once.with('statuses/filter', :track => ['test'], :method => :post) - @client.track('test') + describe '#filter' do + it 'makes a call to "statuses/filter" with the query params provided' do + @client.should_receive(:start).once.with('statuses/filter', :follow => 123, :method => :post) + @client.filter(:follow => 123) + end + it 'makes a call to "statuses/filter" with the query params provided longitude/latitude pairs, separated by commas ' do + @client.should_receive(:start).once.with('statuses/filter', :locations => '-122.75,36.8,-121.75,37.8,-74,40,-73,41', :method => :post) + @client.filter(:locations => '-122.75,36.8,-121.75,37.8,-74,40,-73,41') + end end - it '#track should comma-join multiple arguments' do - @client.should_receive(:start).once.with('statuses/filter', :track => ['foo', 'bar', 'baz'], :method => :post) - @client.track('foo', 'bar', 'baz') - end + describe '#follow' do + it 'makes a call to start with "statuses/filter" and a follow query parameter' do + @client.should_receive(:start).once.with('statuses/filter', :follow => [123], :method => :post) + @client.follow(123) + end - it '#track should comma-join an array of arguments' do - @client.should_receive(:start).once.with('statuses/filter', :track => [['foo','bar','baz']], :method => :post) - @client.track(['foo','bar','baz']) + it 'comma-joins multiple arguments' do + @client.should_receive(:start).once.with('statuses/filter', :follow => [123,456], :method => :post) + @client.follow(123, 456) + end end - it '#follow should make a call to start with "statuses/filter" and a follow query parameter' do - @client.should_receive(:start).once.with('statuses/filter', :follow => [123], :method => :post) - @client.follow(123) - end + describe '#locations' do + it 'should call #start with "statuses/filter" with the query params provided longitude/latitude pairs' do + @client.should_receive(:start).once.with('statuses/filter', :locations => ['-122.75,36.8,-121.75,37.8,-74,40,-73,41'], :method => :post) + @client.locations('-122.75,36.8,-121.75,37.8,-74,40,-73,41') + end - it '#follow should comma-join multiple arguments' do - @client.should_receive(:start).once.with('statuses/filter', :follow => [123,456], :method => :post) - @client.follow(123, 456) + it 'should call #start with "statuses/filter" with the query params provided longitude/latitude pairs and additional filter' do + @client.should_receive(:start).once.with('statuses/filter', :locations => ['-122.75,36.8,-121.75,37.8,-74,40,-73,41'], :track => 'rock', :method => :post) + @client.locations('-122.75,36.8,-121.75,37.8,-74,40,-73,41', :track => 'rock') + end end - it '#filter should make a call to "statuses/filter" with the query params provided' do - @client.should_receive(:start).once.with('statuses/filter', :follow => 123, :method => :post) - @client.filter(:follow => 123) - end - it '#filter should make a call to "statuses/filter" with the query params provided longitude/latitude pairs, separated by commas ' do - @client.should_receive(:start).once.with('statuses/filter', :locations => '-122.75,36.8,-121.75,37.8,-74,40,-73,41', :method => :post) - @client.filter(:locations => '-122.75,36.8,-121.75,37.8,-74,40,-73,41') + describe '#track' do + it 'makes a call to start with "statuses/filter" and a track query parameter' do + @client.should_receive(:start).once.with('statuses/filter', :track => ['test'], :method => :post) + @client.track('test') + end + + it 'comma-joins multiple arguments' do + @client.should_receive(:start).once.with('statuses/filter', :track => ['foo', 'bar', 'baz'], :method => :post) + @client.track('foo', 'bar', 'baz') + end + + it 'comma-joins an array of arguments' do + @client.should_receive(:start).once.with('statuses/filter', :track => [['foo','bar','baz']], :method => :post) + @client.track(['foo','bar','baz']) + end + + it 'should call #start with "statuses/filter" and the provided queries' do + @client.should_receive(:start).once.with('statuses/filter', :track => ['rock'], :method => :post) + @client.track('rock') + end end end @@ -319,25 +342,6 @@ end end - describe '#track' do - it 'should call #start with "statuses/filter" and the provided queries' do - @client.should_receive(:start).once.with('statuses/filter', :track => ['rock'], :method => :post) - @client.track('rock') - end - end - - describe '#locations' do - it 'should call #start with "statuses/filter" with the query params provided longitude/latitude pairs' do - @client.should_receive(:start).once.with('statuses/filter', :locations => ['-122.75,36.8,-121.75,37.8,-74,40,-73,41'], :method => :post) - @client.locations('-122.75,36.8,-121.75,37.8,-74,40,-73,41') - end - - it 'should call #start with "statuses/filter" with the query params provided longitude/latitude pairs and additional filter' do - @client.should_receive(:start).once.with('statuses/filter', :locations => ['-122.75,36.8,-121.75,37.8,-74,40,-73,41'], :track => 'rock', :method => :post) - @client.locations('-122.75,36.8,-121.75,37.8,-74,40,-73,41', :track => 'rock') - end - end - describe '#stop' do it 'should call EventMachine::stop_event_loop' do EventMachine.should_receive :stop_event_loop @@ -352,6 +356,13 @@ end end + describe '#close_connection' do + it 'should not call EventMachine::stop_event_loop' do + EventMachine.should_not_receive :stop_event_loop + TweetStream::Client.new.close_connection.should be_nil + end + end + describe "oauth" do describe '#start' do before do @@ -411,11 +422,4 @@ end end - describe 'instance .close_connection' do - it 'should not call EventMachine::stop_event_loop' do - EventMachine.should_not_receive :stop_event_loop - TweetStream::Client.new.close_connection.should be_nil - end - end - end