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.



961
962
963
964
965
966
967
968
# File 'lib/roby/test/execution_expectations.rb', line 961

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.



959
960
961
# File 'lib/roby/test/execution_expectations.rb', line 959

def generator_model
  @generator_model
end

Instance Method Details

#explain_unachievable(_propagation_info) ⇒ Object



996
997
998
# File 'lib/roby/test/execution_expectations.rb', line 996

def explain_unachievable(_propagation_info)
    @emitted_events.first
end

#format_unachievable_explanation(pp, explanation) ⇒ Object



1004
1005
1006
1007
# File 'lib/roby/test/execution_expectations.rb', line 1004

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

#relates_to_error?(error) ⇒ Boolean

Returns:

  • (Boolean)


1000
1001
1002
# File 'lib/roby/test/execution_expectations.rb', line 1000

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

#to_sObject



970
971
972
# File 'lib/roby/test/execution_expectations.rb', line 970

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

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


992
993
994
# File 'lib/roby/test/execution_expectations.rb', line 992

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

#update_match(propagation_info) ⇒ Object



974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
# File 'lib/roby/test/execution_expectations.rb', line 974

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