Permalink
Browse files

Replaced raise with assert method

  • Loading branch information...
1 parent 4a26ff2 commit af45fad2c04fc8b6c22983b6a59931b0e9cac77b Avdi Grimm committed Jan 8, 2010
Showing with 8 additions and 2 deletions.
  1. +7 −1 lib/cowsay.rb
  2. +1 −1 spec/cowsay_spec.rb
View
@@ -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
View
@@ -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

0 comments on commit af45fad

Please sign in to comment.