Document how to set up response validation with Minitest
TastyPi opened this issue · 5 comments
There's lots of great examples on how to use this library with RSpec, but I can't find anything for Minitest. Is there a way to set up Minitest to validate Apipie responses? If so, could it be documented somewhere?
Hi @TastyPi, I'm looking into this myself now as well. Did you ever find any more resources?
I am assuming using Minitest with ApiPie is possible, it's just we lack documentation.
Maybe you could be more specific about what exactly you want to test?
if I take this spec file for example, that tests a validator.
https://github.com/Apipie/apipie-rails/blob/master/spec/lib/validators/array_validator_spec.rb
converting it from rspec to minitest would mean replacing all the expect().to foo
by some assert bar
; no ?
thanks @mathieujobin for the response
I'm interested in doing something like this as referenced in the docs: https://github.com/Apipie/apipie-rails#example-of-the-manual-mechanism
Our codebase is very tied to Minitest so I don't think introducing RSpec is viable for us to be able to use this.
However based on what you wrote above, I think all that would be required is to convert the following block of code in response_validation_helper.rb
to something that is Minitest compatible?
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
Yes that's correct.
Rspec matcher are just syntaxic sugar...
Définition can be taken pretty much as-is...