Skip to content

Commit

Permalink
Replaced raise with assert method
Browse files Browse the repository at this point in the history
  • Loading branch information
Avdi Grimm committed Jan 8, 2010
1 parent 4a26ff2 commit af45fad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/cowsay.rb
Expand Up @@ -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]}'"
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/cowsay_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit af45fad

Please sign in to comment.