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, #filter_result, #filter_result_with, #format_unachievable_explanation, #unachievable?

Constructor Details

#initialize(event_query, backtrace) ⇒ EmitGeneratorModel

Returns a new instance of EmitGeneratorModel.



1013
1014
1015
1016
1017
1018
1019
# File 'lib/roby/test/execution_expectations.rb', line 1013

def initialize(event_query, backtrace)
    super(backtrace)
    @event_query = event_query
    @generators = []
    @related_error_matchers = []
    @emitted_events = []
end

Instance Attribute Details

#generator_modelObject (readonly)

Returns the value of attribute generator_model.



1011
1012
1013
# File 'lib/roby/test/execution_expectations.rb', line 1011

def generator_model
  @generator_model
end

Instance Method Details

#relates_to_error?(error) ⇒ Boolean

Returns:

  • (Boolean)


1047
1048
1049
# File 'lib/roby/test/execution_expectations.rb', line 1047

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

#return_objectObject



1043
1044
1045
# File 'lib/roby/test/execution_expectations.rb', line 1043

def return_object
    @emitted_events
end

#to_sObject



1021
1022
1023
# File 'lib/roby/test/execution_expectations.rb', line 1021

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

#update_match(propagation_info) ⇒ Object



1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
# File 'lib/roby/test/execution_expectations.rb', line 1025

def update_match(propagation_info)
    @emitted_events =
        propagation_info
        .emitted_events
        .find_all do |ev|
            next unless @event_query === ev.generator

            @generators << ev.generator
            @related_error_matchers <<
                Queries::LocalizedErrorMatcher
                .new
                .with_origin(ev.generator)
                .emitted
                .to_execution_exception_matcher
        end
    !@emitted_events.empty?
end