Permalink
Browse files

Spec out the CucumberFailure.

  • Loading branch information...
1 parent 8f70366 commit 525c7e772d5e8da8423347aedd5b4d36dc027d21 @mathie mathie committed May 4, 2009
Showing with 47 additions and 2 deletions.
  1. +47 −2 spec/ci/reporter/cucumber_spec.rb
View
49 spec/ci/reporter/cucumber_spec.rb
@@ -3,8 +3,53 @@
# software license details.
require File.dirname(__FILE__) + "/../../spec_helper.rb"
-require 'stringio'
+require 'ci/reporter/cucumber'
describe "The Cucumber reporter" do
- it "should work"
+ describe CI::Reporter::CucumberFailure do
+ before(:each) do
+ @klass = mock("class")
+ @klass.stub!(:name).and_return("Exception name")
+
+ @exception = mock("exception")
+ @exception.stub!(:class).and_return(@klass)
+ @exception.stub!(:message).and_return("Exception message")
+ @exception.stub!(:backtrace).and_return(["First line", "Second line"])
+
+ @step = mock("step")
+ @step.stub!(:exception).and_return(@exception)
+
+ @cucumber_failure = CI::Reporter::CucumberFailure.new(@step)
+ end
+
+ it "should always return true for failure?" do
+ @cucumber_failure.should be_failure
+ end
+
+ it "should always return false for error?" do
+ @cucumber_failure.should_not be_error
+ end
+
+ it "should propagate the name as the underlying exception's class name" do
+ @step.should_receive(:exception)
+ @exception.should_receive(:class)
+ @klass.should_receive(:name)
+
+ @cucumber_failure.name.should == "Exception name"
+ end
+
+ it "should propagate the message as the underlying exception's message" do
+ @step.should_receive(:exception)
+ @exception.should_receive(:message)
+
+ @cucumber_failure.message.should == "Exception message"
+ end
+
+ it "should propagate and format the exception's backtrace" do
+ @step.should_receive(:exception)
+ @exception.should_receive(:backtrace)
+
+ @cucumber_failure.location.should == "First line\nSecond line"
+ end
+ end
end

0 comments on commit 525c7e7

Please sign in to comment.