contracts.ruby icon indicating copy to clipboard operation
contracts.ruby copied to clipboard

Args contract failure message contains misleading argument position number

Open waterlink opened this issue 8 years ago • 0 comments

As seen by this scenario I am writing on different branch:

  Scenario: Rejects one invalid argument
    Given a file named "rejects_one_invalid_argument.rb" with:
    """ruby
    require "./args_usage"
    puts Example.new.only_nums(42, "foo", 17, 24)
    """
    When I run `ruby rejects_one_invalid_argument.rb`
    Then the output should contain:
    """
    : Contract violation for argument 1 of 4: (ParamContractError)
            Expected: (Args[Contracts::Builtin::Num]),
            Actual: "foo"
            Value guarded in: Example::only_nums
            With Contract: Args => Bool
    """

It should be either 1 of 1 (as in *args argument), or it should be 2 of 4 as in 2nd argument of all provided.

waterlink avatar Jan 09 '16 22:01 waterlink