Sha256: 57daaa0aa4e6fc6f824eef30476bfd31a59cd6066dc682e80de271bd92c9b058
Contents?: true
Size: 942 Bytes
Versions: 6
Compression:
Stored size: 942 Bytes
Contents
require 'spec_helper' require 'mspec/guards' describe Object, "#with_tty" do before :each do ScratchPad.clear @guard = TTYGuard.new TTYGuard.stub!(:new).and_return(@guard) end it "yields if STDOUT is a TTY" do STDOUT.should_receive(:tty?).and_return(true) with_tty { ScratchPad.record :yield } ScratchPad.recorded.should == :yield end it "does not yield if STDOUT is not a TTY" do STDOUT.should_receive(:tty?).and_return(false) with_tty { ScratchPad.record :yield } ScratchPad.recorded.should_not == :yield end it "sets the name of the guard to :with_tty" do with_tty { } @guard.name.should == :with_tty end it "calls #unregister even when an exception is raised in the guard block" do @guard.should_receive(:match?).and_return(true) @guard.should_receive(:unregister) lambda do with_tty { raise Exception } end.should raise_error(Exception) end end
Version data entries
6 entries across 6 versions & 1 rubygems