Sha256: e94451ef12275ef7d012afe16517001842774e466e7b30a5e439e0de2e8a3ba0

Contents?: true

Size: 908 Bytes

Versions: 3

Compression:

Stored size: 908 Bytes

Contents

require 'rib/test'
require 'rib/more/beep'

describe Rib::Beep do
  paste :rib

  before do
    Rib::Beep.enable
  end

  after do
    expect(Rib::Beep).disabled?
  end

  def verify delay, threshold=nil, &block
    new_shell(:started_at => Time.now - delay,
              :beep_threshold => threshold, &block)
  end

  def expect_beep shell
    mock(shell).print("\a"){}
  end

  def unexpect_beep shell
    stub(shell).print.with_any_args{ flunk }
  end

  describe 'beep' do
    would 'beep if loading too long' do
      verify(10, &method(:expect_beep))
    end

    would 'be configurable via beep_threshold' do
      verify(2, 1, &method(:expect_beep))
    end
  end

  describe 'not beep' do
    would 'not beep if not loading long' do
      verify(2, &method(:unexpect_beep))
    end

    would 'be configurable via beep_threshold' do
      verify(10, 15, &method(:unexpect_beep))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rib-1.5.4 test/more/test_beep.rb
rib-1.5.3 test/more/test_beep.rb
rib-1.5.2 test/more/test_beep.rb