spec/theatre/invocation_spec.rb in adhearsion-1.2.4 vs spec/theatre/invocation_spec.rb in adhearsion-1.2.5

- old
+ new

@@ -62,9 +62,30 @@ invocation.current_state.should == :error invocation.should be_error invocation.error.should be_instance_of(ArgumentError) end + it "should trigger an exception event if an exception was raised" do + invocation = Theatre::Invocation.new("/namespace/whatever", lambda { raise ArgumentError, "this error is intentional" }) + flexmock(Adhearsion::Events).should_receive(:trigger).once.with('/exception', FlexMock.any) + invocation.queued + invocation.start + end + + it "should NOT trigger an exception if the exception occurs in an exception namespace" do + invocation = Theatre::Invocation.new("/exception", lambda { raise ArgumentError, "this error is intentional" }) + flexmock(Adhearsion::Events).should_receive(:trigger).never + invocation.queued + invocation.start + end + + it "should do the right thing with exceptions triggered with the wrong namespace" do + invocation = Theatre::Invocation.new(['exception'], lambda { raise ArgumentError, "this error is intentional" }) + flexmock(Adhearsion::Events).should_receive(:trigger).never + invocation.queued + invocation.start + end + it "should have a status of :success if no expection was raised" do callback = lambda { "No errors raised here!" } invocation = Theatre::Invocation.new("/namespace/whatever", callback) invocation.queued invocation.start