Skip to content

Contract.valid? does not return data about the failure #262

@alexevanczuk

Description

@alexevanczuk

I'm writing a custom rspec matcher that validates the input and output arguments that are being stubbed out obey the specified contract. I'm doing this by calling Contract.valid? against the contract after pulling it using decorated_methods_for. The documentation for #valid? says that it returns metadata about the nature of the failure, but I am getting nil. I'd like the matcher to just raise the original ParamContractError when there is an error, which I'm doing by just re-calling the original method, but I'd prefer to just surface the contract failure up front explicitly.

Better yet, I'd like to just do Contract.validate!(args, contract) but this doesn't seem to be a public API. Was wondering if I could get some help with this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions