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

#filter_result, #filter_result_with, #format_unachievable_explanation, #relates_to_error?

Constructor Details

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

Returns a new instance of Maintain.



1337
1338
1339
1340
1341
1342
1343
1344
# File 'lib/roby/test/execution_expectations.rb', line 1337

def initialize(at_least_during, block, description, backtrace)
    super(backtrace)
    @at_least_during = at_least_during
    @description = description || @backtrace[0].to_s
    @block = block
    @deadline = Time.now_without_mock_time + at_least_during
    @failed = false
end

Instance Method Details

#explain_unachievable(_propagation_info) ⇒ Object



1359
1360
1361
# File 'lib/roby/test/execution_expectations.rb', line 1359

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

#to_sObject



1363
1364
1365
1366
1367
1368
1369
# File 'lib/roby/test/execution_expectations.rb', line 1363

def to_s
    if @description.respond_to?(:call)
        @description.call
    else
        @description
    end
end

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


1355
1356
1357
# File 'lib/roby/test/execution_expectations.rb', line 1355

def unachievable?(_propagation_info)
    @failed
end

#update_match(propagation_info) ⇒ Object



1346
1347
1348
1349
1350
1351
1352
1353
# File 'lib/roby/test/execution_expectations.rb', line 1346

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