Class: Roby::Test::ExecutionExpectations::Maintain

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

#relates_to_error?

Constructor Details

#initialize(at_least_during, block, description, backtrace) ⇒ Maintain

Returns a new instance of Maintain.



1043
1044
1045
1046
1047
1048
1049
1050
# File 'lib/roby/test/execution_expectations.rb', line 1043

def initialize(at_least_during, block, description, backtrace)
    super(backtrace)
    @at_least_during = at_least_during
    @description = description
    @block = block
    @deadline = Time.now + at_least_during
    @failed = false
end

Instance Method Details

#explain_unachievable(propagation_info) ⇒ Object



1065
1066
1067
# File 'lib/roby/test/execution_expectations.rb', line 1065

def explain_unachievable(propagation_info)
    "#{self} returned false"
end

#to_sObject



1069
1070
1071
1072
1073
1074
1075
# File 'lib/roby/test/execution_expectations.rb', line 1069

def to_s
    if @description
        @description
    else
        @backtrace[0].to_s
    end
end

#unachievable?(propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


1061
1062
1063
# File 'lib/roby/test/execution_expectations.rb', line 1061

def unachievable?(propagation_info)
    @failed
end

#update_match(propagation_info) ⇒ Object



1052
1053
1054
1055
1056
1057
1058
1059
# File 'lib/roby/test/execution_expectations.rb', line 1052

def update_match(propagation_info)
    if !@block.call(propagation_info)
        @failed = true
        return false
    elsif Time.now > @deadline
        return true
    end
end