Class: SpecForge::Forge::Runner::ContentValidator
- Inherits:
-
Object
- Object
- SpecForge::Forge::Runner::ContentValidator
- Defined in:
- lib/spec_forge/forge/runner/content_validator.rb
Overview
Validates JSON content against expected matchers
Recursively walks through the response body and expected values, running RSpec matchers at each leaf node and collecting failures.
Instance Method Summary collapse
-
#initialize(data, expected) ⇒ ContentValidator
constructor
Creates a new content validator.
-
#validate! ⇒ void
Validates the data against expected content matchers.
Constructor Details
#initialize(data, expected) ⇒ ContentValidator
Creates a new content validator
21 22 23 24 25 |
# File 'lib/spec_forge/forge/runner/content_validator.rb', line 21 def initialize(data, expected) @data = data @expected = expected @failures = [] end |
Instance Method Details
#validate! ⇒ void
This method returns an undefined value.
Validates the data against expected content matchers
34 35 36 37 38 |
# File 'lib/spec_forge/forge/runner/content_validator.rb', line 34 def validate! check_content(@data, @expected, path: "") raise Error::ContentValidationFailure.new(@failures) if @failures.any? end |