Sha256: 39bb70d817946b3378656f722bdd908b2d73f9730b93bb0227a0c6502564c7a2
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
require 'spec_helper' class WaiterStub include Mohawk::Waiter end describe Mohawk::Waiter do Given(:waiter) do allow_any_instance_of(WaiterStub).to receive(:sleep) {} WaiterStub.new end def fake_time(*times) expect(Time).to receive(:now).exactly(times.count).times.and_return(*times) end def do_it @fake_responses.shift end context 'default timeout' do When { fake_time 0, 30, 60.1 } Then { expect { waiter.wait_until { false } }.to raise_error Mohawk::WaitTimeout } end context 'specific timeout' do When { fake_time 0, 30, 30.1 } Then { expect { waiter.wait_until(30) { false } }.to raise_error Mohawk::WaitTimeout } end context 'waits in between' do When do @fake_responses = [false, true] fake_time 0, 1 end Then { expect { waiter.wait_until { do_it } }.not_to raise_error } end context 'accepts context parameter' do Then { expect { waiter.wait_until(1, 'This is the context') { true } }.not_to raise_error } end context 'outputs context on error' do Then do context_string = 'This is the context' expect { waiter.wait_until(1, context_string) { false } }.to raise_error Mohawk::Waiter::WaitTimeout, context_string end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mohawk-1.0 | spec/lib/mohawk/waiter_spec.rb |
mohawk-0.4.4 | spec/lib/mohawk/waiter_spec.rb |
mohawk-0.4.3 | spec/lib/mohawk/waiter_spec.rb |