Class: RSpec::Jasmine::ExampleResult
- Inherits:
-
Hash
- Object
- Hash
- RSpec::Jasmine::ExampleResult
- Defined in:
- lib/rspec/jasmine/example_result.rb
Instance Method Summary collapse
- #backtrace ⇒ Object
- #error_message ⇒ Object
- #failed? ⇒ Boolean
- #failure ⇒ Object
-
#initialize(results) ⇒ ExampleResult
constructor
A new instance of ExampleResult.
- #merge_backtrace_with!(e) ⇒ Object
- #scream! ⇒ Object
Constructor Details
#initialize(results) ⇒ ExampleResult
Returns a new instance of ExampleResult.
4 5 6 7 |
# File 'lib/rspec/jasmine/example_result.rb', line 4 def initialize(results) super() merge!(results) end |
Instance Method Details
#backtrace ⇒ Object
31 32 33 34 35 36 |
# File 'lib/rspec/jasmine/example_result.rb', line 31 def backtrace trace = failure['trace'] || {} trace['stack'].to_s.split(/$/).map(&:strip).delete_if do |line| line =~ /\/lib\/jasmine-\d+\.\d+\.\d+\/jasmine\.js\:\d+/ || line.strip.empty? end end |
#error_message ⇒ Object
17 18 19 |
# File 'lib/rspec/jasmine/example_result.rb', line 17 def failure['message'].to_s end |
#failed? ⇒ Boolean
9 10 11 |
# File 'lib/rspec/jasmine/example_result.rb', line 9 def failed? self['result'] == 'failed' end |
#failure ⇒ Object
13 14 15 |
# File 'lib/rspec/jasmine/example_result.rb', line 13 def failure @failed_message ||= self['messages'].to_a.find { |m| m['passed'] == false } end |
#merge_backtrace_with!(e) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/rspec/jasmine/example_result.rb', line 21 def merge_backtrace_with!(e) e.instance_variable_set('@stack', self.backtrace) class << e def backtrace return @stack end end end |
#scream! ⇒ Object
38 39 40 41 42 |
# File 'lib/rspec/jasmine/example_result.rb', line 38 def scream! if failed? raise RSpec::Expectations::ExpectationNotMetError.new() end end |