Class: Roby::Test::ExpectExecution::Context

Inherits:
Struct
  • Object
show all
Defined in:
lib/roby/test/expect_execution.rb

Overview

The context object that allows the expect_execution { }.to { } syntax

Constant Summary collapse

SETUP_METHODS =
[
:timeout,
:wait_until_timeout,
:join_all_waiting_work,
:scheduler,
:garbage_collect,
:validate_unexpected_errors,
:display_exceptions]

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



55
56
57
58
# File 'lib/roby/test/expect_execution.rb', line 55

def method_missing(m, *args)
    expectations.public_send(m, *args)
    self
end

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



41
42
43
# File 'lib/roby/test/expect_execution.rb', line 41

def block
  @block
end

#expectationsObject

Returns the value of attribute expectations

Returns:

  • (Object)

    the current value of expectations



41
42
43
# File 'lib/roby/test/expect_execution.rb', line 41

def expectations
  @expectations
end

#testObject

Returns the value of attribute test

Returns:

  • (Object)

    the current value of test



41
42
43
# File 'lib/roby/test/expect_execution.rb', line 41

def test
  @test
end

Instance Method Details

#respond_to_missing?(m, include_private) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/roby/test/expect_execution.rb', line 51

def respond_to_missing?(m, include_private)
    SETUP_METHODS.include?(m)
end

#to(&expectation_block) ⇒ Object

Declare the expectations and run



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/roby/test/expect_execution.rb', line 69

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.message, caller(2)
ensure
    test.reset_current_expect_execution
end

#to_runObject

Run the block without any expectations

Expectations might be added dynamically by the block given to expect_execution using Roby::Test::ExpectExecution#add_expectations



64
65
66
# File 'lib/roby/test/expect_execution.rb', line 64

def to_run
    to
end