Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove some connection.close duplication from the specs

  • Loading branch information...
commit 94b48e44cb8549ea93a63540b513cf191a6edf00 1 parent 5a881e6
@joshk joshk authored
View
1  spec/application_spec.rb
@@ -12,7 +12,6 @@
app.stubs(:logger).returns(Logger.new(StringIO.new))
end
-
describe 'start' do
it 'starts the workers with the given names' do
workers.expects(:start).with(['worker-1'])
View
10 spec/factory_spec.rb
@@ -8,10 +8,7 @@
let(:worker) { factory.worker }
describe 'worker' do
- after :each do
- worker.shutdown
- connection.close if connection.open?
- end
+ after(:each) { worker.shutdown }
it 'returns a worker' do
worker.should be_a(Travis::Worker)
@@ -22,11 +19,6 @@
end
describe 'queues' do
- after :each do
- worker.shutdown
- connection.close
- end
-
it 'includes individual build queues that were listed in the configuration' do
worker.queue_names.should include("builds.php")
worker.queue_names.should include("builds.python")
View
16 spec/pool_spec.rb
@@ -14,10 +14,6 @@
end
describe 'start' do
- after :each do
- connection.close
- end
-
describe 'with no worker names given' do
it 'starts the workers' do
workers.each { |worker| worker.expects(:start) }
@@ -44,10 +40,6 @@
describe 'stop' do
describe 'with no worker names given' do
- after :each do
- connection.close
- end
-
it 'stops the workers' do
workers.each { |worker| worker.expects(:stop) }
pool.stop([])
@@ -55,10 +47,6 @@
end
describe 'with a worker name given' do
- after :each do
- connection.close
- end
-
it 'stops the worker' do
workers.first.expects(:stop)
pool.stop(['worker-1'])
@@ -75,10 +63,6 @@
end
describe 'with an option :force => true given' do
- after :each do
- connection.close
- end
-
it 'stops the worker with that option' do
workers.first.expects(:stop).with(:force => true)
pool.stop(['worker-1'], :force => true)
View
4 spec/reporters/log_streamer_spec.rb
@@ -17,10 +17,6 @@
queue.bind(reporting_exchange, :routing_key => routing_key)
end
- after :each do
- connection.close
- end
-
it "publishes log chunks" do
reporter.notify('build:log', :log => "...")
sleep 0.5
View
8 spec/reporters/state_reporter_spec.rb
@@ -12,7 +12,6 @@
include Travis::Serialization
-
before :each do
Travis.logger = Logger.new(io)
Travis.logger.level = Logger::DEBUG
@@ -22,9 +21,6 @@
before :each do
queue.purge
end
- after :each do
- connection.close
- end
it "publishes notifications of given type" do
reporter.notify('build:started', :hostname => "giove.local")
@@ -37,10 +33,6 @@
end
describe 'logging' do
- after :each do
- connection.close
- end
-
it 'logs before :message is being called' do
reporter.notify('build:started', :foo => "bar")
io.string.should include('about to message')
View
2  spec/support/hot_bunnies.rb
@@ -1,4 +1,4 @@
shared_context "hot_bunnies connection" do
let(:connection) { HotBunnies.connect(:hostname => "127.0.0.1") }
- after(:all) { connection.close }
+ after(:each) { connection.close }
end
View
74 spec/worker_spec.rb
@@ -28,10 +28,6 @@
end
describe 'start' do
- after :each do
- connection.close if connection.open?
- end
-
it 'sets the current state to :starting while it prepares the vm' do
state = nil
vm.stubs(:prepare).with { state = worker.state } # hrmm, mocha doesn't support spies, does it?
@@ -60,17 +56,9 @@
end
end
-
-
describe 'stop' do
after :each do
worker.shutdown
- connection.close
- end
-
- after :all do
- worker.shutdown
- connection.close
end
describe 'if the worker is still working' do
@@ -106,18 +94,10 @@
end
end
-
-
describe 'process' do
describe 'without any exception rescued' do
- before :each do
- worker.state = :ready
- end
-
- after :each do
- worker.shutdown
- connection.close
- end
+ before(:each) { worker.state = :ready }
+ after(:each) { worker.shutdown }
it 'works' do
worker.expects(:work)
@@ -135,10 +115,8 @@
after :each do
worker.shutdown
- connection.close
end
-
it 'responds to the error' do
worker.expects(:error).with(exception, metadata)
worker.send(:process, metadata, payload)
@@ -146,23 +124,9 @@
end
end
-
-
describe 'work' do
- before :each do
- worker.state = :ready
- end
-
- after :each do
- worker.shutdown
- connection.close
- end
-
- after :all do
- worker.shutdown
- connection.close
- end
-
+ before(:each) { worker.state = :ready }
+ after(:each) { worker.shutdown }
it 'prepares work' do
worker.expects(:prepare)
@@ -186,15 +150,7 @@
end
describe 'prepare' do
- after :each do
- worker.shutdown
- connection.close
- end
-
- after :all do
- worker.shutdown
- connection.close
- end
+ after(:each) { worker.shutdown }
it 'sets the current payload' do
worker.send(:prepare, payload)
@@ -208,15 +164,7 @@
end
describe 'finish' do
- after :each do
- worker.shutdown
- connection.close
- end
-
- after :all do
- worker.shutdown
- connection.close
- end
+ after(:each) { worker.shutdown }
it 'unsets the current payload' do
worker.send(:prepare, '{ "id": 1 }')
@@ -239,15 +187,7 @@
end
describe 'error' do
- after :each do
- worker.shutdown
- connection.close
- end
-
- after :all do
- worker.shutdown
- connection.close
- end
+ after(:each) { worker.shutdown }
it 'requeues the message' do
metadata.expects(:ack).with(:requeue => true)
Please sign in to comment.
Something went wrong with that request. Please try again.