Browse files

Switched assertion example to assert cowfile not blank

  • Loading branch information...
1 parent 84ddeef commit 52a52efe6af3921d9c75fde488efb85d1000bc2e @avdi committed Jan 10, 2010
Showing with 3 additions and 5 deletions.
  1. +1 −1 lib/cowsay.rb
  2. +2 −4 spec/cowsay_spec.rb
View
2 lib/cowsay.rb
@@ -8,7 +8,7 @@ def initialize(options={})
end
def say(message, options={})
- assert(options[:cowfile].nil? || File.exist?(options[:cowfile]))
+ options[:cowfile] and assert(options[:cowfile].to_s !~ /^\s*$/)
command = "cowsay"
if options[:strings] && options[:strings][:eyes]
command << " -e '#{options[:strings][:eyes]}'"
View
6 spec/cowsay_spec.rb
@@ -112,17 +112,15 @@ def set_child_exit_status(status)
context "given a cowfile" do
it "should supply a -f argument on the command line" do
- File.stub!(:exist?).and_return(true)
@io_class.should_receive(:popen).with(/-f COWFILE/, anything)
@it.say("moo", :cowfile => "COWFILE")
end
end
- context "given an invalid cowfile" do
+ context "given a blank cowfile" do
it "should raise an error" do
- File.stub!(:exist?).and_return(false)
lambda do
- @it.say("moo", :cowfile => "COWFILE")
+ @it.say("moo", :cowfile => " ")
end.should raise_error(Exception)
end
end

0 comments on commit 52a52ef

Please sign in to comment.