diff --git a/lib/cowsay.rb b/lib/cowsay.rb index 0974600..a1c2793 100644 --- a/lib/cowsay.rb +++ b/lib/cowsay.rb @@ -9,7 +9,7 @@ def initialize(options={}) def say(message, options={}) out = options[:out] - raise ArgumentError unless out.nil? || out.respond_to?(:<<) + assert(out.nil? || out.respond_to?(:<<)) command = "cowsay" if options[:strings] && options[:strings][:eyes] command << " -e '#{options[:strings][:eyes]}'" @@ -47,5 +47,11 @@ def say(message, options={}) end output end + + private + + def assert(value, message="Assertion failed") + raise Exception, message unless value + end end end diff --git a/spec/cowsay_spec.rb b/spec/cowsay_spec.rb index 1ba8436..138096c 100644 --- a/spec/cowsay_spec.rb +++ b/spec/cowsay_spec.rb @@ -114,7 +114,7 @@ def set_child_exit_status(status) it "should raise ArgumentError" do lambda do @it.say("whatever", :out => Object.new) - end.should raise_error(ArgumentError) + end.should raise_error end end end