Module: NormalizedHash::Matchers
- Included in:
- RSpec::Matchers
- Defined in:
- lib/version.rb,
lib/normalized_hash/matchers.rb,
lib/normalized_hash/hash_keys.rb,
lib/normalized_hash/hash_values.rb,
lib/normalized_hash/array_values.rb,
lib/normalized_hash/hash_enclosed_in_array.rb
Defined Under Namespace
Classes: ArrayValues, HashEnclosingArray, HashKeys, HashMatchers, HashValues, KeyNameMatchers, KeyNamesOfEnclosedHash, SameArrayValues
Constant Summary collapse
- VERSION =
"0.0.1"
- NUMBERS =
All numeric classes we want to consider
[Fixnum, Bignum, Numeric, Float]
Instance Method Summary collapse
- #all_arrays_have_hash_with_key_word_name_or_singular_of_hash_key ⇒ Object
-
#have_all_keys_be_word_name_or_singular_of(expected) ⇒ Object
Test that array has only elements of expeted class(es).
-
#have_array_values_in_class(expected) ⇒ Object
Test that array has only elements of expeted class(es).
-
#have_array_values_of_the_same_class ⇒ Object
Test that array elements are all in the same class.
-
#have_keys_in_class(expected) ⇒ Object
Test that hash has only keys of expected class(es).
-
#have_values_in_class(expected) ⇒ Object
Test that hash has only values of expected class(es).
Instance Method Details
#all_arrays_have_hash_with_key_word_name_or_singular_of_hash_key ⇒ Object
18 19 20 |
# File 'lib/normalized_hash/hash_enclosed_in_array.rb', line 18 def all_arrays_have_hash_with_key_word_name_or_singular_of_hash_key HashEnclosingArray.new end |
#have_all_keys_be_word_name_or_singular_of(expected) ⇒ Object
Test that array has only elements of expeted class(es).
Usage
it { @TODO.should TODO }
14 15 16 |
# File 'lib/normalized_hash/hash_enclosed_in_array.rb', line 14 def have_all_keys_be_word_name_or_singular_of (expected) KeyNamesOfEnclosedHash.new(expected) end |
#have_array_values_in_class(expected) ⇒ Object
Test that array has only elements of expeted class(es).
Array is a value in deep (multilevel) hash. Check done hierarchically for all arrays’ values.
Usage
it { @hash.should have_array_values_in_class [String,Numeric,Hash] }
it { @hash.should have_array_values_in_class Numeric }
15 16 17 |
# File 'lib/normalized_hash/array_values.rb', line 15 def have_array_values_in_class(expected) ArrayValues.new(expected) end |
#have_array_values_of_the_same_class ⇒ Object
Test that array elements are all in the same class.
Array is a value in deep (multilevel) hash. Check done hierarchically for all arrays’ values.
Usage
it { @hash.should have_array_values_of_the_same_class }
29 30 31 32 |
# File 'lib/normalized_hash/array_values.rb', line 29 def have_array_values_of_the_same_class SameArrayValues.new Object # dummy class, not used but needs to # be here because of constructor end |
#have_keys_in_class(expected) ⇒ Object
Test that hash has only keys of expected class(es).
Check done hierarchically for all Hashes.
Usage
it { @hash.should have_keys_in_class [String,Numeric,Hash,Array] }
it { @hash.should have_keys_in_class Numeric }
14 15 16 |
# File 'lib/normalized_hash/hash_keys.rb', line 14 def have_keys_in_class(expected) HashKeys.new(expected) end |
#have_values_in_class(expected) ⇒ Object
Test that hash has only values of expected class(es).
Check done hierarchically for all Hashes.
Usage
it { @hash.should have_values_in_class [String,Numeric,Hash,Array] }
it { @hash.should have_values_in_class Numeric }
15 16 17 |
# File 'lib/normalized_hash/hash_values.rb', line 15 def have_values_in_class(expected) HashValues.new(expected) end |