Class: Riot::RR::Assertion

Inherits:
Assertion show all
Defined in:
lib/riot/rr.rb

Overview

Binds the Assertion to RR so that successes and failures found by RR are inherently handled during an assertion evaluation. In effect, if RR suggests failure during validation, the assertion will fail and report these failures.

Instance Attribute Summary

Attributes inherited from Riot::RunnableBlock

#definition

Instance Method Summary collapse

Methods inherited from Assertion

#initialize, macros, register_macro

Methods inherited from Riot::RunnableBlock

#initialize, #to_s

Constructor Details

This class inherits a constructor from Riot::Assertion

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Riot::Assertion

Instance Method Details

#run(situation) ⇒ Array<Symbol, String>

Adds RR support to Assertion#run. The basic flow is to:

  • run the test as normal

  • ask RR to verify mock results

  • report any errors or return the result of the assertion as normal

  • reset RR so that the next assertion in the context can be verified cleanly.

Parameters:

Returns:

  • (Array<Symbol, String>)

    array containing evaluation state and a descriptive explanation



32
33
34
35
36
37
38
39
40
# File 'lib/riot/rr.rb', line 32

def run(situation)
  result = super
  situation.verify
  result
rescue ::RR::Errors::RRError => e
  result.first == :pass ? [:fail, e.message.gsub(/\n/, " ")] : result
ensure
  situation.reset
end