Class: Roby::Test::ExecutionExpectations::EmitGeneratorModel

Inherits:
Expectation show all
Defined in:
lib/roby/test/execution_expectations.rb

Instance Attribute Summary collapse

Attributes inherited from Expectation

#backtrace

Instance Method Summary collapse

Methods inherited from Expectation

#explain_unachievable, #unachievable?

Constructor Details

#initialize(event_query, backtrace) ⇒ EmitGeneratorModel

Returns a new instance of EmitGeneratorModel.



772
773
774
775
776
777
778
# File 'lib/roby/test/execution_expectations.rb', line 772

def initialize(event_query, backtrace)
    super(backtrace)
    @event_query = event_query
    @generators = Array.new
    @related_error_matchers = Array.new
    @emitted_events = Array.new
end

Instance Attribute Details

#generator_modelObject (readonly)

Returns the value of attribute generator_model.



770
771
772
# File 'lib/roby/test/execution_expectations.rb', line 770

def generator_model
  @generator_model
end

Instance Method Details

#relates_to_error?(error) ⇒ Boolean

Returns:

  • (Boolean)


801
802
803
# File 'lib/roby/test/execution_expectations.rb', line 801

def relates_to_error?(error)
    @related_error_matchers.any? { |match| match === error }
end

#return_objectObject



797
798
799
# File 'lib/roby/test/execution_expectations.rb', line 797

def return_object
    @emitted_events
end

#to_sObject



780
781
782
# File 'lib/roby/test/execution_expectations.rb', line 780

def to_s
    "at least one event matching #{@event_query} should be emitted"
end

#update_match(propagation_info) ⇒ Object



784
785
786
787
788
789
790
791
792
793
794
795
# File 'lib/roby/test/execution_expectations.rb', line 784

def update_match(propagation_info)
    @emitted_events = propagation_info.emitted_events.
        find_all do |ev|
            if @event_query === ev.generator
                @generators << ev.generator
                @related_error_matchers << Queries::LocalizedErrorMatcher.new.
                    with_origin(ev.generator).
                    to_execution_exception_matcher
            end
        end
    !@emitted_events.empty?
end