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.



1332
1333
1334
1335
1336
1337
1338
1339
# File 'lib/roby/test/execution_expectations.rb', line 1332

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



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

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

#to_sObject



1358
1359
1360
1361
1362
1363
1364
# File 'lib/roby/test/execution_expectations.rb', line 1358

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

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


1350
1351
1352
# File 'lib/roby/test/execution_expectations.rb', line 1350

def unachievable?(_propagation_info)
    @failed
end

#update_match(propagation_info) ⇒ Object



1341
1342
1343
1344
1345
1346
1347
1348
# File 'lib/roby/test/execution_expectations.rb', line 1341

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