Skip to content

Commit

Permalink
some test refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
stve committed Dec 8, 2011
1 parent c66629f commit faf26e6
Showing 1 changed file with 54 additions and 50 deletions.
104 changes: 54 additions & 50 deletions spec/tweetstream/client_spec.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit faf26e6

Please sign in to comment.