test/workers/forking_worker_test.rb in backburner-1.1.0 vs test/workers/forking_worker_test.rb in backburner-1.2.0.pre
- old
+ new
@@ -17,61 +17,58 @@
it "should watch specified tubes" do
worker = @worker_class.new(["foo", "bar"])
out = capture_stdout { worker.prepare }
assert_equal ["demo.test.foo", "demo.test.bar"], worker.tube_names
- assert_same_elements ["demo.test.foo", "demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
+ assert_same_elements ["demo.test.foo", "demo.test.bar"], worker.connection.tubes.watched.map(&:name)
assert_match(/demo\.test\.foo/, out)
end # multiple
it "should watch single tube" do
worker = @worker_class.new("foo")
out = capture_stdout { worker.prepare }
assert_equal ["demo.test.foo"], worker.tube_names
- assert_same_elements ["demo.test.foo"], @worker_class.connection.tubes.watched.map(&:name)
+ assert_same_elements ["demo.test.foo"], worker.connection.tubes.watched.map(&:name)
assert_match(/demo\.test\.foo/, out)
end # single
it "should respect default_queues settings" do
Backburner.default_queues.concat(["foo", "bar"])
worker = @worker_class.new
out = capture_stdout { worker.prepare }
assert_equal ["demo.test.foo", "demo.test.bar"], worker.tube_names
- assert_same_elements ["demo.test.foo", "demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
+ assert_same_elements ["demo.test.foo", "demo.test.bar"], worker.connection.tubes.watched.map(&:name)
assert_match(/demo\.test\.foo/, out)
end
it "should assign based on all tubes" do
@worker_class.any_instance.expects(:all_existing_queues).once.returns("bar")
worker = @worker_class.new
out = capture_stdout { worker.prepare }
assert_equal ["demo.test.bar"], worker.tube_names
- assert_same_elements ["demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
+ assert_same_elements ["demo.test.bar"], worker.connection.tubes.watched.map(&:name)
assert_match(/demo\.test\.bar/, out)
end # all assign
it "should properly retrieve all tubes" do
worker = @worker_class.new
out = capture_stdout { worker.prepare }
assert_contains worker.tube_names, "demo.test.backburner-jobs"
- assert_contains @worker_class.connection.tubes.watched.map(&:name), "demo.test.backburner-jobs"
- assert_match(/demo\.test\.test-job/, out)
+ assert_contains worker.connection.tubes.watched.map(&:name), "demo.test.backburner-jobs"
+ assert_match(/demo\.test\.backburner-jobs/, out)
end # all read
end # prepare
describe "for fork_one_job method" do
- it "should fork, reconnect, work job, and exit" do
+ it "should fork, work job, and exit" do
clear_jobs!("bar.foo")
@worker_class.enqueue TestJobForking, [1, 2], :queue => "bar.foo"
fake_pid = 45
- Process.expects(:fork).returns(fake_pid) do |&block|
- Connection.expects(:new).with(Backburner.configuration.beanstalk_url)
- @worker_class.any_instance.expects(:work_one_job)
- @worker_class.any_instance.expects(:coolest_exit)
- block.call
- end
+ Process.expects(:fork).returns(fake_pid).yields
+ @worker_class.any_instance.expects(:work_one_job)
+ @worker_class.any_instance.expects(:coolest_exit)
Process.expects(:wait).with(fake_pid)
silenced(2) do
worker = @worker_class.new('bar.foo')
worker.prepare