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

ContractError should also show the arguments that caused the error #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

egonSchiele
Copy link
Owner

Output:

contracts.ruby (adit/215) $ cat test.rb
require "contracts"
include Contracts

Contract Num => Num
def incr x
  "Sdf"
end

incr(23)
contracts.ruby (adit/215) $ ruby test.rb
/Users/abhargava/contracts.ruby/lib/contracts.rb:45:in `block in <class:Contract>': Contract violation for return value: (ReturnContractError)
        Expected: Num,
        Actual: "Sdf"
        Value guarded in: Object::incr
        With Contract: Num => Num
        All arguments: [23]
        At: test.rb:5
    from /Users/abhargava/contracts.ruby/lib/contracts.rb:155:in `call'
    from /Users/abhargava/contracts.ruby/lib/contracts.rb:155:in `failure_callback'
    from /Users/abhargava/contracts.ruby/lib/contracts/call_with.rb:82:in `call_with'
    from /Users/abhargava/contracts.ruby/lib/contracts/method_handler.rb:138:in `block in redefine_method'
    from test.rb:9:in `<main>'

cc @waterlink @beezee (for issue #215)

@egonSchiele
Copy link
Owner Author

Oh man, I forgot I need to update the output in the Cucumber tests :/

@waterlink
Copy link
Collaborator

This is a very useful feature

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

Successfully merging this pull request may close these issues.

2 participants