Class: ExceptionState
- Defined in:
- lib/extensions/mspec/mspec/runner/exception.rb
Instance Attribute Summary collapse
-
#describe ⇒ Object
readonly
Returns the value of attribute describe.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#it ⇒ Object
readonly
Returns the value of attribute it.
Instance Method Summary collapse
- #backtrace ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(state, location, exception) ⇒ ExceptionState
constructor
A new instance of ExceptionState.
- #message ⇒ Object
Constructor Details
#initialize(state, location, exception) ⇒ ExceptionState
Returns a new instance of ExceptionState.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/extensions/mspec/mspec/runner/exception.rb', line 4 def initialize(state, location, exception) @exception = exception @description = location ? "An exception occurred during: #{location}" : "" if state @description << "\n" unless @description.empty? @description << state.description @describe = state.describe @it = state.it else @describe = @it = "" end end |
Instance Attribute Details
#describe ⇒ Object (readonly)
Returns the value of attribute describe.
2 3 4 |
# File 'lib/extensions/mspec/mspec/runner/exception.rb', line 2 def describe @describe end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
2 3 4 |
# File 'lib/extensions/mspec/mspec/runner/exception.rb', line 2 def description @description end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
2 3 4 |
# File 'lib/extensions/mspec/mspec/runner/exception.rb', line 2 def exception @exception end |
#it ⇒ Object (readonly)
Returns the value of attribute it.
2 3 4 |
# File 'lib/extensions/mspec/mspec/runner/exception.rb', line 2 def it @it end |
Instance Method Details
#backtrace ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/extensions/mspec/mspec/runner/exception.rb', line 33 def backtrace @backtrace_filter ||= MSpecScript.config[:backtrace_filter] begin bt = @exception.awesome_backtrace.show.split "\n" rescue Exception bt = @exception.backtrace || [] end bt.select { |line| $MSPEC_DEBUG or @backtrace_filter !~ line }.join("\n") end |
#failure? ⇒ Boolean
18 19 20 |
# File 'lib/extensions/mspec/mspec/runner/exception.rb', line 18 def failure? [SpecExpectationNotMetError, SpecExpectationNotFoundError].any? { |e| @exception.is_a? e } end |
#message ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/extensions/mspec/mspec/runner/exception.rb', line 22 def if @exception..empty? "<No message>" elsif @exception.class == SpecExpectationNotMetError || @exception.class == SpecExpectationNotFoundError @exception. else "#{@exception.class}: #{@exception.}" end end |