None
Usage
Hash#assert_valid_keys gives you the ability to verify that each of the keys in the Hash are expected. For example, if you take an options Hash as an argument to a method you may want to validate that only expected options are passed as part of the hash; assert_valid_keys gives you the ability to list the keys you expect.
Test
unit_tests do
test "raise argument error on unexpected key" do
assert_raises ArgumentError do
{:invalid_key => :a, :valid_key => :b}.assert_valid_keys(:valid_key)
end
end
end
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.