Class: CI::Reporter::RSpec2::Failure
- Inherits:
-
Object
- Object
- CI::Reporter::RSpec2::Failure
- Defined in:
- lib/ci/reporter/rspec2/failure.rb
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #failure? ⇒ Boolean
-
#initialize(example, formatter) ⇒ Failure
constructor
A new instance of Failure.
- #location ⇒ Object
- #message ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(example, formatter) ⇒ Failure
Returns a new instance of Failure.
6 7 8 9 10 11 12 13 14 |
# File 'lib/ci/reporter/rspec2/failure.rb', line 6 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 Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
4 5 6 |
# File 'lib/ci/reporter/rspec2/failure.rb', line 4 def exception @exception end |
Instance Method Details
#error? ⇒ Boolean
28 29 30 |
# File 'lib/ci/reporter/rspec2/failure.rb', line 28 def error? !failure? end |
#failure? ⇒ Boolean
24 25 26 |
# File 'lib/ci/reporter/rspec2/failure.rb', line 24 def failure? exception.is_a?(::RSpec::Expectations::ExpectationNotMetError) end |
#location ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ci/reporter/rspec2/failure.rb', line 32 def location output = [] output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/ output.push @exception. [@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 |
#message ⇒ Object
20 21 22 |
# File 'lib/ci/reporter/rspec2/failure.rb', line 20 def @exception. end |
#name ⇒ Object
16 17 18 |
# File 'lib/ci/reporter/rspec2/failure.rb', line 16 def name @exception.class.name end |