mirror of https://github.com/rails/rails
Tidy up previous commit, fix message assertion and improve tests
This commit is contained in:
parent
2ebf47aea2
commit
c48a0cac62
|
@ -67,7 +67,9 @@ class Hash
|
|||
def assert_valid_keys(*valid_keys)
|
||||
valid_keys.flatten!
|
||||
each_key do |k|
|
||||
raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}") unless valid_keys.include?(k)
|
||||
unless valid_keys.include?(k)
|
||||
raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -624,10 +624,15 @@ class HashExtTest < ActiveSupport::TestCase
|
|||
{ :failure => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny)
|
||||
end
|
||||
|
||||
assert_raise(ArgumentError, "Unknown key: :failore. Valid keys are: :failure, :funny") do
|
||||
exception = assert_raise ArgumentError do
|
||||
{ :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ])
|
||||
end
|
||||
assert_equal "Unknown key: :failore. Valid keys are: :failure, :funny", exception.message
|
||||
|
||||
exception = assert_raise ArgumentError do
|
||||
{ :failore => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny)
|
||||
end
|
||||
assert_equal "Unknown key: :failore. Valid keys are: :failure, :funny", exception.message
|
||||
end
|
||||
|
||||
def test_assorted_keys_not_stringified
|
||||
|
|
Loading…
Reference in New Issue