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.



857
858
859
860
861
862
863
864
865
866
867
868
# File 'lib/roby/test/execution_expectations.rb', line 857

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



887
888
889
# File 'lib/roby/test/execution_expectations.rb', line 887

def explain_unachievable(_propagation_info)
    @emitted_events.first
end

#format_unachievable_explanation(pp, explanation) ⇒ Object



895
896
897
898
# File 'lib/roby/test/execution_expectations.rb', line 895

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

#relates_to_error?(error) ⇒ Boolean

Returns:

  • (Boolean)


891
892
893
# File 'lib/roby/test/execution_expectations.rb', line 891

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

#to_sObject



870
871
872
# File 'lib/roby/test/execution_expectations.rb', line 870

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

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


883
884
885
# File 'lib/roby/test/execution_expectations.rb', line 883

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

#update_match(propagation_info) ⇒ Object



874
875
876
877
878
879
880
881
# File 'lib/roby/test/execution_expectations.rb', line 874

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