Permalink
Browse files

compatibility with rspec 2.2+, backwards compatible with rspec 1.x/2.0

  • Loading branch information...
1 parent 41818fd commit e2a84d2049a7a90f84e5fb5d6838d75a244fd09b Daniel Weaver & Stephan "Zed" Zuercher: sz committed Dec 21, 2010
Showing with 21 additions and 1 deletion.
  1. +1 −1 lib/ci/reporter/rspec.rb
  2. +20 −0 spec/ci/reporter/rspec_spec.rb
View
@@ -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?
@@ -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.