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.



1275
1276
1277
1278
1279
1280
1281
1282
# File 'lib/roby/test/execution_expectations.rb', line 1275

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



1297
1298
1299
# File 'lib/roby/test/execution_expectations.rb', line 1297

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

#to_sObject



1301
1302
1303
1304
1305
1306
1307
# File 'lib/roby/test/execution_expectations.rb', line 1301

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

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


1293
1294
1295
# File 'lib/roby/test/execution_expectations.rb', line 1293

def unachievable?(_propagation_info)
    @failed
end

#update_match(propagation_info) ⇒ Object



1284
1285
1286
1287
1288
1289
1290
1291
# File 'lib/roby/test/execution_expectations.rb', line 1284

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