Class: Roby::Test::ExecutionExpectations::NotEmitGenerator

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

Instance Attribute Summary

Attributes inherited from Expectation

#backtrace

Instance Method Summary collapse

Methods inherited from Expectation

#filter_result, #filter_result_with

Constructor Details

#initialize(generator, backtrace, within: 0.5) ⇒ NotEmitGenerator

Returns a new instance of NotEmitGenerator.



914
915
916
917
918
919
920
921
922
923
924
925
# File 'lib/roby/test/execution_expectations.rb', line 914

def initialize(generator, backtrace, within: 0.5)
    super(backtrace)
    @generator = generator
    @emitted_events = []
    @related_error_matcher =
        Queries::LocalizedErrorMatcher
        .new
        .with_origin(@generator)
        .to_execution_exception_matcher

    @deadline = Time.now_without_mock_time + within
end

Instance Method Details

#explain_unachievable(_propagation_info) ⇒ Object



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

def explain_unachievable(_propagation_info)
    @emitted_events.first
end

#format_unachievable_explanation(pp, explanation) ⇒ Object



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

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

#relates_to_error?(error) ⇒ Boolean

Returns:

  • (Boolean)


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

def relates_to_error?(error)
    @related_error_matcher === error
end

#to_sObject



927
928
929
# File 'lib/roby/test/execution_expectations.rb', line 927

def to_s
    "#{@generator} should not be emitted"
end

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#update_match(propagation_info) ⇒ Object



931
932
933
934
935
936
937
938
# File 'lib/roby/test/execution_expectations.rb', line 931

def update_match(propagation_info)
    @emitted_events +=
        propagation_info
        .emitted_events
        .find_all { |ev| ev.generator == @generator }

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