Sha256: e974a9fd003999e7807b2b607fed902d4be22707080b49c34d0c03b5d9510f3d
Contents?: true
Size: 776 Bytes
Versions: 22
Compression:
Stored size: 776 Bytes
Contents
require 'facet/hash/has_keys' class Hash # Returns true is hash has the given keys, # otherwise throws an ArgumentError. # # h = { :a => 1, :b => 2 } # h.assert_has_keys( :a ) #=> true # h.assert_has_keys( :c ) #=> ArgumentError # def assert_has_keys(*check_keys) raise(ArgumentError, "does not have key(s)") unless has_keys?(*check_keys) end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCHash < Test::Unit::TestCase def test_assert_has_keys assert_nothing_raised { { :a=>1,:b=>2,:c=>3 }.assert_has_keys(:a,:b) } assert_raises( ArgumentError ) { { :a=>1,:b=>2,:c=>3 }.assert_has_keys(:d) } end end =end
Version data entries
22 entries across 22 versions & 1 rubygems
Version | Path |
---|---|
facets-1.8.20 | lib/facets/core/hash/assert_has_keys.rb |
facets-1.8.8 | lib/facets/core/hash/assert_has_keys.rb |