Permalink
Browse files

'eyes' option demonstrating &&

  • Loading branch information...
1 parent 63b5111 commit 683f80c7890b81855cda8eeefb6cca8b17521848 Avdi Grimm committed Dec 28, 2009
Showing with 10 additions and 1 deletion.
  1. +5 −1 lib/cowsay.rb
  2. +5 −0 spec/cowsay_spec.rb
View
@@ -5,7 +5,11 @@ def initialize(options={})
end
def say(message, options={})
- @io_class.popen("cowsay", "w+") do |process|
+ command = "cowsay"
+ if options[:strings] && options[:strings][:eyes]
+ command << " -e '#{options[:strings][:eyes]}'"
+ end
+ @io_class.popen(command, "w+") do |process|
process.write(message)
process.close_write
result = process.read
View
@@ -45,5 +45,10 @@ module Cowsay
@it.say("moo", :out => out)
out.string.should be == "OUTPUT"
end
+
+ it "should pass the -e flag if 'eyes' string set" do
+ @io_class.should_receive(:popen).with(/\-e 'oO\'/, anything)
+ @it.say("moo", :strings => { :eyes => 'oO' })
+ end
end
end

0 comments on commit 683f80c

Please sign in to comment.