Sha256: 2fa5c1b4a648de0e5fcba4c46d7ff8a1a7faf42dcaba3887166a605cb2f93646

Contents?: true

Size: 601 Bytes

Versions: 10

Compression:

Stored size: 601 Bytes

Contents

require 'spec_helper'
require 'timers/wait'

RSpec.describe Timers::Wait do
  it "repeats until timeout expired" do
    timeout = Timers::Wait.new(5)
    count = 0
    
    timeout.while_time_remaining do |remaining|
      expect(remaining).to be_within(TIMER_QUANTUM).of (timeout.duration - count)
      
      count += 1
      sleep 1
    end
    
    expect(count).to eq(5)
  end
  
  it "yields results as soon as possible" do
    timeout = Timers::Wait.new(5)
    
    result = timeout.while_time_remaining do |remaining|
      break :done
    end
    
    expect(result).to eq(:done)
  end
end

Version data entries

10 entries across 8 versions & 4 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/timers-4.0.0/spec/timeout_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/timers-4.0.0/spec/timeout_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/timers-4.0.0/spec/timeout_spec.rb
timers-4.0.4 spec/timeout_spec.rb
timers-4.1.1 spec/timeout_spec.rb
timers-4.1.0 spec/timeout_spec.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/timers-4.0.1/spec/timeout_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/timers-4.0.1/spec/timeout_spec.rb
timers-4.0.1 spec/timeout_spec.rb
timers-4.0.0 spec/timeout_spec.rb