Skip to content
Browse files

Format backtraces when reporting with ci_reporter

  • Loading branch information...
1 parent 4b804b0 commit 8f24b174e2dc151de8f78ddaf664ed194e51319b @mgiambalvo mgiambalvo committed
Showing with 15 additions and 2 deletions.
  1. +15 −2 lib/ci/reporter/rspec.rb
View
17 lib/ci/reporter/rspec.rb
@@ -49,7 +49,8 @@ def location() (exception.backtrace || ["No backtrace available"]).join("\n") en
end
class RSpec2Failure < RSpecFailure
- def initialize(example)
+ def initialize(example, formatter)
+ @formatter = formatter
@example = example
@exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered]
end
@@ -57,6 +58,18 @@ def initialize(example)
def failure?
exception.is_a?(::RSpec::Expectations::ExpectationNotMetError)
end
+
+ def location()
+ output = []
+ output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/
+ output.push @exception.message
+
+ @formatter.format_backtrace(@exception.backtrace, @example).each do |backtrace_info|
+ output.push backtrace_info
+ end
+
+ output.join '\n'
+ end
end
# Custom +RSpec+ formatter used to hook into the spec runs and capture results.
@@ -110,7 +123,7 @@ def example_failed(name_or_example, *rest)
example_started(name_or_example) if @suite.testcases.empty?
if name_or_example.respond_to?(:execution_result) # RSpec 2
- failure = RSpec2Failure.new(name_or_example)
+ failure = RSpec2Failure.new(name_or_example, @formatter)
else
failure = RSpecFailure.new(rest[1]) # example_failed(name, counter, failure) in RSpec 1
end

0 comments on commit 8f24b17

Please sign in to comment.
Something went wrong with that request. Please try again.