Class: CI::Reporter::RSpec2Failure

Inherits:
RSpecFailure show all
Defined in:
lib/ci/reporter/rspec.rb

Instance Attribute Summary

Attributes inherited from RSpecFailure

#exception

Instance Method Summary collapse

Methods inherited from RSpecFailure

#error?

Constructor Details

#initialize(example, formatter) ⇒ RSpec2Failure

Returns a new instance of RSpec2Failure.



52
53
54
55
56
# File 'lib/ci/reporter/rspec.rb', line 52

def initialize(example, formatter)
  @formatter = formatter
  @example = example
  @exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered]
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/ci/reporter/rspec.rb', line 66

def failure?
  exception.is_a?(::RSpec::Expectations::ExpectationNotMetError)
end

#locationObject



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ci/reporter/rspec.rb', line 70

def location
  output = []
  output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/
  output.push @exception.message

  [@formatter.format_backtrace(@exception.backtrace, @example)].flatten.each do |backtrace_info|
    backtrace_info.lines.each do |line|
      output.push "     #{line}"
    end
  end
  output.join "\n"
end

#messageObject



62
63
64
# File 'lib/ci/reporter/rspec.rb', line 62

def message
  @exception.message
end

#nameObject



58
59
60
# File 'lib/ci/reporter/rspec.rb', line 58

def name
  @exception.class.name
end