require 'rib/test' require 'rib/more/beep' describe Rib::Beep do paste :rib before do Rib::Beep.enable end def verify delay, threshold=nil, &block shell(:started_at => Time.now - delay, :beep_threshold => threshold, &block) stub_output mock(shell).get_input{} shell.loop ok end def expect_beep sh mock(sh).print("\a"){} end def unexpect_beep sh stub(sh).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