spec/cukeforker/runner_spec.rb in cukeforker-0.1.0 vs spec/cukeforker/runner_spec.rb in cukeforker-0.1.1

- old
+ new

@@ -42,10 +42,21 @@ VncListener.should_receive(:new).with(mock_pool).and_return mock(:update => nil) Runner.create([], :max => 2, :vnc => true) end + it "sets up VNC recording if :record => true" do + mock_pool = mock(VncTools::ServerPool, :add_observer => nil) + VncTools::ServerPool.should_receive(:new).with(2).and_return mock_pool + + mock_vnc_listener = mock(:update => nil) + VncListener.should_receive(:new).with(mock_pool).and_return(mock_vnc_listener) + RecordingVncListener.should_receive(:new).with(mock_vnc_listener).and_return(mock(:update => nil)) + + Runner.create([], :max => 2, :vnc => true, :record => true) + end + it "creates and runs a new runner" do r = mock(Runner) Runner.should_receive(:create).with(%w[a b], {}).and_return(r) r.should_receive(:run) @@ -75,9 +86,19 @@ queue.stub(:process).and_raise(Interrupt) runner.stub(:stop) listener.should_receive(:update).with(:on_run_interrupted) runner.run + end + + it "fires on_run_interrupted and shuts down if an error occurs" do + runner.add_observer listener + + queue.stub(:process).and_raise(StandardError) + runner.stub(:stop) + listener.should_receive(:update).with(:on_run_interrupted) + + lambda { runner.run }.should raise_error(StandardError) end end end # Runner end # CukeForker