Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Test Validation support for MiniTest #940

Open
simonireilly opened this issue Jul 16, 2024 · 0 comments
Open

Feature: Test Validation support for MiniTest #940

simonireilly opened this issue Jul 16, 2024 · 0 comments

Comments

@simonireilly
Copy link

simonireilly commented Jul 16, 2024

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant