Class: NormalizedHash::Matchers::HashMatchers
- Inherits:
-
Object
- Object
- NormalizedHash::Matchers::HashMatchers
- Defined in:
- lib/normalized_hash/matchers.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(expectation) ⇒ HashMatchers
constructor
A new instance of HashMatchers.
Constructor Details
#initialize(expectation) ⇒ HashMatchers
Returns a new instance of HashMatchers.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/normalized_hash/matchers.rb', line 9 def initialize(expectation) # Convert to array for simpler checks @expectation = [expectation].flatten # All expectionations should be Class, no other classes unless @expectation.map(&:class).uniq == [Class] raise ArgumentError, "#{@expectation.inspect}: Expectation should be Class or Array[of Classes], got #{@expectation.class}" end # Expand expectation with all numeric classes if at least one # numeric present. (@expectation += NUMBERS).uniq! unless (@expectation & NUMBERS).empty? end |