-
Notifications
You must be signed in to change notification settings - Fork 460
Description
Background
The test validation helpers are a great binding between implementation and outcome. This closes the loop between DSL code in controllers and the actual API behaviour.
By asserting the behaviour against the docs, the docs remain valid, through time and changes; and are therefore easier to maintain; and drift is prevented.
See response validation here
Issue
They lack MiniTest Support.
Changes
The Rspec specific code is only this portion of the lib
apipie-rails/lib/apipie/rspec/response_validation_helper.rb
Lines 130 to 157 in 4be3741
| RSpec::Matchers.define :match_declared_responses do | |
| match do |actual| | |
| (schema, validation_errors) = subject.send(:schema_validation_errors_for_response) | |
| valid = (validation_errors == []) | |
| Apipie::print_validation_errors(validation_errors, schema, response) unless valid | |
| valid | |
| end | |
| end | |
| #--------------------------------- | |
| # Auto-validation logic | |
| #--------------------------------- | |
| module RSpec::Rails::ViewRendering | |
| # Augment the RSpec DSL | |
| module ClassMethods | |
| def auto_validate_rendered_views | |
| before do | |
| @is_response_validation_on = true | |
| end | |
| after do | |
| @is_response_validation_on = false | |
| end | |
| end | |
| end | |
| end |
A refactor to have the Test helpers injected into the controllers moved separate to the test helpers used by the invoking test framework would add support for any type of testing framework.
Intention
I can support making this change to make minitest work with this through the proposed refactor.