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
57
58
59
60
# File 'lib/ci/reporter/rspec.rb', line 52

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

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/ci/reporter/rspec.rb', line 70

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

#locationObject



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ci/reporter/rspec.rb', line 74

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



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

def message
  @exception.message
end

#nameObject



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

def name
  @exception.class.name
end