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.



956
957
958
959
960
961
962
# File 'lib/roby/test/execution_expectations.rb', line 956

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.



954
955
956
# File 'lib/roby/test/execution_expectations.rb', line 954

def generator_model
  @generator_model
end

Instance Method Details

#relates_to_error?(error) ⇒ Boolean

Returns:

  • (Boolean)


990
991
992
# File 'lib/roby/test/execution_expectations.rb', line 990

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

#return_objectObject



986
987
988
# File 'lib/roby/test/execution_expectations.rb', line 986

def return_object
    @emitted_events
end

#to_sObject



964
965
966
# File 'lib/roby/test/execution_expectations.rb', line 964

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

#update_match(propagation_info) ⇒ Object



968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
# File 'lib/roby/test/execution_expectations.rb', line 968

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