Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Raise ArgumentError instead of general exception

  • Loading branch information...
commit 3300780a1f11a467e17df444ca585aadcb93260a 1 parent 7df415f
@maxjustus authored
Showing with 6 additions and 6 deletions.
  1. +1 −1  lib/str8jacket.rb
  2. +5 −5 spec/str8_spec.rb
View
2  lib/str8jacket.rb
@@ -96,7 +96,7 @@ def validate_arg_class(arg = @arg, conversion = @conversion, msg = '')
end
def argument_error(arg, conversion, type_msg, conversion_message = 'does not respond to')
- raise "Argument #{arg.inspect} #{type_msg} at position #{index} #{conversion_message} #{conversion}".split(' ').join(' ')
+ raise ArgumentError, "Argument #{arg.inspect} #{type_msg} at position #{index} #{conversion_message} #{conversion}".split(' ').join(' ')
end
end
end
View
10 spec/str8_spec.rb
@@ -49,11 +49,11 @@ def mom(options, random_integer_flag, random_array_arg)
instance.herp(1, {}, 'LOL?')
-> do
instance.herp('a', 1)
- end.should raise_exception('Argument "a" at position 0 does not respond to to_int')
+ end.should raise_exception(ArgumentError, 'Argument "a" at position 0 does not respond to to_int')
-> do
instance.herp(1, 111)
- end.should raise_exception('Argument 111 at position 1 does not respond to to_hash')
+ end.should raise_exception(ArgumentError, 'Argument 111 at position 1 does not respond to to_hash')
-> do
instance.derp({})
@@ -75,11 +75,11 @@ def mom(options, random_integer_flag, random_array_arg)
-> do
instance.login(1, {})
- end.should raise_exception('Argument 1 at position 0 is not an instance of User')
+ end.should raise_exception(ArgumentError, 'Argument 1 at position 0 is not an instance of User')
-> do
instance.login(User.new, {User.new => 'stuff'})
- end.should raise_exception('Argument "stuff" (value in hash) at position 1 is not an instance of Integer')
+ end.should raise_exception(ArgumentError, 'Argument "stuff" (value in hash) at position 1 is not an instance of Integer')
end
it 'validates and enforces hash and array argument types' do
@@ -88,7 +88,7 @@ def mom(options, random_integer_flag, random_array_arg)
-> do
instance.hash_validation({['herp'] => :derp}, ['1'])
- end.should raise_exception('Argument ["herp"] (key in hash) at position 0 does not respond to to_sym')
+ end.should raise_exception(ArgumentError, 'Argument ["herp"] (key in hash) at position 0 does not respond to to_sym')
end
it 'enforces type of return value' do
Please sign in to comment.
Something went wrong with that request. Please try again.