Skip to content

Commit

Permalink
compatibility with rspec 2.2+, backwards compatible with rspec 1.x/2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Weaver & Stephan "Zed" Zuercher: sz committed Dec 21, 2010
1 parent 41818fd commit e2a84d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ci/reporter/rspec.rb
Expand Up @@ -51,7 +51,7 @@ def location() (exception.backtrace || ["No backtrace available"]).join("\n") en
class RSpec2Failure < RSpecFailure
def initialize(example)
@example = example
@exception = @example.execution_result[:exception_encountered]
@exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered]
end

def failure?
Expand Down
20 changes: 20 additions & 0 deletions spec/ci/reporter/rspec_spec.rb
Expand Up @@ -123,4 +123,24 @@
@fmt.example_failed("should fail", 1, @error)
@fmt.dump_summary(0.1, 1, 0, 0)
end

describe 'RSpec2Failure' do
before(:each) do
@rspec20_example = mock('RSpec2.0 Example', :execution_result => {:exception_encountered => StandardError.new('rspec2.0 ftw')})
@rspec22_example = mock('RSpec2.2 Example', :execution_result => {:exception => StandardError.new('rspec2.2 ftw')})
end

it 'should handle rspec (< 2.2) execution results' do
failure = CI::Reporter::RSpec2Failure.new(@rspec20_example)
failure.name.should_not be_nil
failure.message.should == 'rspec2.0 ftw'
failure.location.should_not be_nil
end
it 'should handle rspec (>= 2.2) execution results' do
failure = CI::Reporter::RSpec2Failure.new(@rspec22_example)
failure.name.should_not be_nil
failure.message.should == 'rspec2.2 ftw'
failure.location.should_not be_nil
end
end
end

0 comments on commit e2a84d2

Please sign in to comment.