Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
Spec out the CucumberFailure.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathie committed May 4, 2009
1 parent 8f70366 commit 525c7e7
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions spec/ci/reporter/cucumber_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.