Class: RSpec::JsonMatchers::Expectations::Mixins::BuiltIn::HashWithContent
- Inherits:
-
Core::SingleValueCallableExpectation
- Object
- RSpec::JsonMatchers::Expectation
- Core::CallableExpectation
- Core::SingleValueCallableExpectation
- RSpec::JsonMatchers::Expectations::Mixins::BuiltIn::HashWithContent
- Defined in:
- lib/rspec/json_matchers/expectations/mixins/built_in.rb
Overview
Takes a Hash Validates value to be Hash and contain expected keys & values Extra keys in value will not be treated as “unexpected” Unless #with_exact_keys is used
Instance Method Summary collapse
- #expect?(value) ⇒ Boolean
-
#with_exact_keys ⇒ Object
After calling this method Any extra key in
valuewill be marked as “unexpected”.
Methods inherited from Core::SingleValueCallableExpectation
Methods inherited from Core::CallableExpectation
Methods inherited from RSpec::JsonMatchers::Expectation
Instance Method Details
#expect?(value) ⇒ Boolean
207 208 209 210 211 |
# File 'lib/rspec/json_matchers/expectations/mixins/built_in.rb', line 207 def expect?(value) matches_expected_class?(value) && matches_content_expectations?(value) && matches_keys_exactly?(value) end |
#with_exact_keys ⇒ Object
After calling this method Any extra key in value will be marked as “unexpected”
By default the expectation won’t care about extra keys in value
217 218 219 220 |
# File 'lib/rspec/json_matchers/expectations/mixins/built_in.rb', line 217 def with_exact_keys @require_exact_key_matches = true self end |