cucumber-expressions wrong number of arguments (given 0, expected 1)
langalex opened this issue · 22 comments
Summary
Just upgraded:
cucumber (3.0.2 → 3.1.0)
cucumber-core (3.0.0 → 3.1.0)
cucumber-expressions (4.0.4 → 5.0.17)
cucumber-tag_expressions (1.0.1 → 1.1.1)
gherkin (4.1.3 → 5.0.0)
cucumber-rails (1.5.0 → 1.6.0)
and now I'm getting a wrong number of arguments (given 0, expected 1) (ArgumentError)
in cucumber-expressions.
Expected Behavior
There should be no ArgumentError.
Current Behavior
When running my tests, I get an ArgumentError in cucumber-expressions-5.0.17/lib/cucumber/cucumber_expressions/parameter_type_registry.rb:17:in
block in initialize'`.
Stacktrace:
cucumber-expressions-5.0.17/lib/cucumber/cucumber_expressions/parameter_type_registry.rb:17:in `block in initialize'
cucumber-expressions-5.0.17/lib/cucumber/cucumber_expressions/parameter_type.rb:38:in `instance_exec'
cucumber-expressions-5.0.17/lib/cucumber/cucumber_expressions/parameter_type.rb:38:in `transform'
cucumber-expressions-5.0.17/lib/cucumber/cucumber_expressions/argument.rb:33:in `value'
cucumber-3.1.0/lib/cucumber/step_match.rb:18:in `block in args'
cucumber-3.1.0/lib/cucumber/step_match.rb:17:in `map'
cucumber-3.1.0/lib/cucumber/step_match.rb:17:in `args'
cucumber-3.1.0/lib/cucumber/step_match.rb:97:in `deep_clone_args'
cucumber-3.1.0/lib/cucumber/step_match.rb:29:in `invoke'
cucumber-3.1.0/lib/cucumber/step_match.rb:24:in `block in activate'
...
Possible Solution
The line causing the error looks like this:
define_parameter_type(ParameterType.new('int', INTEGER_REGEXPS, Integer, lambda {|s| s.to_i}, true, true))
The error comes from the arity of the lambda
being one, but it's called in paramter_type.rb:38
with no args: self_obj.instance_exec(*group_values, &@transformer)
(@transformer
is the lambda from above).
I have no idea what's going on there, but there's already another commit fixing the arity of other lambdas. Could this be connected?
Steps to Reproduce (for bugs)
- upgrade cucumber-expressions to 5.0.17
- run tests
Sorry this is happening in a closed source repo. I can try to create a small test repo to expose the problem, but maybe it's a quick fix for someone who knows more about the code base.
Context & Motivation
Tests are broken.
Your Environment
- Version used: cucumber-expressions 5.0.17, Ruby 2.3.6
- Operating System and version: MacOS 10.13.4
- Link to your project: -
Possibly related issue cucumber/common#375 - does it work with expressions 5.0.15?
Yes, 5.0.15 works.
@langalex I can't reproduce this when using the latest version of cucumber-ruby
(in master
). Could you please try using the git repo in your Gemfile, to see if one of the unreleased improvements resolves the issue?
gem 'cucumber-ruby', git: 'git://github.com/cucumber/cucumber-ruby.git'
with gem 'cucumber', git: 'git://github.com/cucumber/cucumber-ruby.git'
(including cucumber-expressions 5.0.17) everything is green 👍
Brilliant, thanks for confirming that, @langalex!
@xtrasimplicity thanks for putting in the time!
Not a problem. I'll close this one off for the moment as it will be resolved with the release of 3.1.1. :)
@xtrasimplicity - cucumber/common#380 isn't released yet, so I'm not sure the bug is fixed.
@langalex can you provide us with a Minimal, Complete, and Verifiable example in a git repo please? We need that to reproduce the bug and verify that it's fixed.
Thanks @aslakhellesoy. I've reopened this in the meantime. Did you want me to hold off on releasing cucumber-ruby 3.1.1
until the latest changes to cucumber-expressions
are released?
Yes please
@langalex bundle exec cucumber
passes for me in that repo. Are you seeing something else?
@aslakhellesoy well, it does fail on travis. I ran bundle exec cucumber features/test.feature
but same with just bundle exec cucumber
.
also, it's still failing with gem 'cucumber', git: 'git://github.com/cucumber/cucumber-ruby.git'
(cucumber-master branch). but it works with cucumber-expressions 5.0.15.
I ran it on Ruby 2.5.1, where it passes. Then tried on 2.3.6, where it fails.
This needs some more investigation. Thanks for the mcve @langalex - that will make it easier to fix.
I experienced same issue (Ruby 2.4.4 and cucumber-expression 5.0.16, with 5.0.15 issue didn't happen).
After investigation I found that step definition with regex like that:
^[blabla ]?[Bb]bla[Blabla ]?(?:| (\d+))$
was causing it.
After simplifying regex it work with latest versions of cucumber-expression.
Thanks for investigating this, @alexbaranovskyi!
I can confirm that v5.0.18 (from the source) works for me with the changes made in https://github.com/cucumber/cucumber/pull/380/files#diff-0035aaedf2d4a9c0687063ec6d379192, on Ruby 2.3.6, 2.4.3 and 2.5.0, with the CVE that @langalex posted. 👍
# Gemfile
gem 'cucumber-expressions', git: 'https://github.com/cucumber/cucumber', ref: '8ffca85', glob: 'cucumber-expressions/ruby/*.gemspec'
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.
I say this is fixed and can be closed.
Thanks, @langalex!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.