Sha256: d682494bbf80e172fd8aab41bcdd12d968050a91908a68dab697e885414ebcaa
Contents?: true
Size: 975 Bytes
Versions: 8
Compression:
Stored size: 975 Bytes
Contents
require File.dirname(__FILE__) + '/../spec_helper' require 'mspec/guards/tty' 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
8 entries across 8 versions & 1 rubygems