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.



57
58
59
60
61
62
63
64
65
# File 'lib/ci/reporter/rspec.rb', line 57

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)


75
76
77
# File 'lib/ci/reporter/rspec.rb', line 75

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

#locationObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ci/reporter/rspec.rb', line 79

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

   = RSpecFormatters::RSpec_2_12_0_bug ? @example. : @example

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

#messageObject



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

def message
  @exception.message
end

#nameObject



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

def name
  @exception.class.name
end