Class: Spec::Runner::Reporter::Failure

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/runner/reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context_name, spec_name, exception) ⇒ Failure

Returns a new instance of Failure.



84
85
86
87
88
# File 'lib/spec/runner/reporter.rb', line 84

def initialize(context_name, spec_name, exception)
  @context_name = context_name
  @spec_name = spec_name
  @exception = exception
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



82
83
84
# File 'lib/spec/runner/reporter.rb', line 82

def exception
  @exception
end

Instance Method Details

#expectation_not_met?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/spec/runner/reporter.rb', line 98

def expectation_not_met?
  @exception.is_a?(Spec::Expectations::ExpectationNotMetError)
end

#headerObject



90
91
92
93
94
95
96
# File 'lib/spec/runner/reporter.rb', line 90

def header
  if expectation_not_met?
    "'#{@context_name} #{@spec_name}' FAILED"
  else
    "#{@exception.class.name} in '#{@context_name} #{@spec_name}'"
  end
end