Sha256: 384d1367267ef6cf16c43288bc9a991d9285c5f39ccd59ee197b402906408761
Contents?: true
Size: 797 Bytes
Versions: 2
Compression:
Stored size: 797 Bytes
Contents
module WildcardMatchers module Matchers def is_a(klass) klass end [ String, Integer, Float, Hash, Array ].each do |klass| module_eval %{ def is_a_#{klass.to_s.downcase} #{klass.inspect} end } end def is_bool lambda {|bool| TrueClass === bool or FalseClass === bool } end def is_time lambda do |time| require "time" time.is_a?(Time) or (Time.parse(time) rescue false) end end # RSpeck::Mocks has hash_including def hash_includes(*args) hash_to_match = {} hash_to_match = args.pop if args.last.is_a?(Hash) lambda do |hash| (args - hash.keys).size == 0 && hash_to_match.all? {|key, value| value === hash[key] } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wildcard_matchers-0.0.2 | lib/wildcard_matchers/matchers.rb |
wildcard_matchers-0.0.1 | lib/wildcard_matchers/matchers.rb |