Class: Roby::Test::ExecutionExpectations::NotEmitGeneratorModel

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

#filter_result, #filter_result_with

Constructor Details

#initialize(event_query, backtrace, within: 0.5) ⇒ NotEmitGeneratorModel

Returns a new instance of NotEmitGeneratorModel.



904
905
906
907
908
909
910
911
# File 'lib/roby/test/execution_expectations.rb', line 904

def initialize(event_query, backtrace, within: 0.5)
    super(backtrace)
    @event_query = event_query
    @generators = []
    @related_error_matchers = []
    @emitted_events = []
    @deadline = Time.now_without_mock_time + within
end

Instance Attribute Details

#generator_modelObject (readonly)

Returns the value of attribute generator_model.



902
903
904
# File 'lib/roby/test/execution_expectations.rb', line 902

def generator_model
  @generator_model
end

Instance Method Details

#explain_unachievable(_propagation_info) ⇒ Object



939
940
941
# File 'lib/roby/test/execution_expectations.rb', line 939

def explain_unachievable(_propagation_info)
    @emitted_events.first
end

#format_unachievable_explanation(pp, explanation) ⇒ Object



947
948
949
950
# File 'lib/roby/test/execution_expectations.rb', line 947

def format_unachievable_explanation(pp, explanation)
    pp.text "but one was: "
    explanation.pretty_print(pp)
end

#relates_to_error?(error) ⇒ Boolean

Returns:

  • (Boolean)


943
944
945
# File 'lib/roby/test/execution_expectations.rb', line 943

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

#to_sObject



913
914
915
# File 'lib/roby/test/execution_expectations.rb', line 913

def to_s
    "no events matching #{@event_query} should be emitted"
end

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


935
936
937
# File 'lib/roby/test/execution_expectations.rb', line 935

def unachievable?(_propagation_info)
    !@emitted_events.empty?
end

#update_match(propagation_info) ⇒ Object



917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
# File 'lib/roby/test/execution_expectations.rb', line 917

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)
                .to_execution_exception_matcher
        end

    @emitted_events.empty? if Time.now_without_mock_time > @deadline
end