Class: Roby::Test::ExpectExecution::Context
- Defined in:
- lib/roby/test/expect_execution.rb
Overview
The context object that allows the expect_execution { }.to { } syntax
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#expectations ⇒ Object
Returns the value of attribute expectations.
-
#test ⇒ Object
Returns the value of attribute test.
Instance Method Summary collapse
- #method_missing(m, *args, **kw, &block) ⇒ Object
- #respond_to_missing?(m, include_private) ⇒ Boolean
-
#to(&expectation_block) ⇒ Object
Declare the expectations and run.
-
#to_run ⇒ Object
Run the block without any expectations.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, **kw, &block) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/roby/test/expect_execution.rb', line 59 def method_missing(m, *args, **kw, &block) if (to_method = m.to_s.match(/^to_/)) return to { send(to_method.post_match, *args, **kw, &block) } end expectations.public_send(m, *args, **kw, &block) self end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block
54 55 56 |
# File 'lib/roby/test/expect_execution.rb', line 54 def block @block end |
#expectations ⇒ Object
Returns the value of attribute expectations
54 55 56 |
# File 'lib/roby/test/expect_execution.rb', line 54 def expectations @expectations end |
#test ⇒ Object
Returns the value of attribute test
54 55 56 |
# File 'lib/roby/test/expect_execution.rb', line 54 def test @test end |
Instance Method Details
#respond_to_missing?(m, include_private) ⇒ Boolean
55 56 57 |
# File 'lib/roby/test/expect_execution.rb', line 55 def respond_to_missing?(m, include_private) SETUP_METHODS.include?(m) end |
#to(&expectation_block) ⇒ Object
Declare the expectations and run
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/roby/test/expect_execution.rb', line 77 def to(&expectation_block) test.setup_current_expect_execution(self) if expectation_block expectations.parse(&expectation_block) end expectations.verify(&block) rescue Minitest::Assertion => e raise e, e., caller(2) ensure test.reset_current_expect_execution end |
#to_run ⇒ Object
Run the block without any expectations
Expectations might be added dynamically by the block given to expect_execution using Roby::Test::ExpectExecution#add_expectations
72 73 74 |
# File 'lib/roby/test/expect_execution.rb', line 72 def to_run to end |