Skip to content

Feature: Test Validation support for MiniTest #940

@simonireilly

Description

@simonireilly

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions