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

cucumber-expressions wrong number of arguments (given 0, expected 1) #1292

Closed
langalex opened this issue Apr 23, 2018 · 22 comments
Closed

cucumber-expressions wrong number of arguments (given 0, expected 1) #1292

langalex opened this issue Apr 23, 2018 · 22 comments

Comments

@langalex
Copy link

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)

  1. upgrade cucumber-expressions to 5.0.17
  2. 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: -
@viraptor
Copy link

Possibly related issue cucumber/common#375 - does it work with expressions 5.0.15?

@langalex
Copy link
Author

Yes, 5.0.15 works.

@xtrasimplicity xtrasimplicity mentioned this issue May 11, 2018
7 tasks
@xtrasimplicity
Copy link
Member

@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'

@langalex
Copy link
Author

with gem 'cucumber', git: 'git://github.com/cucumber/cucumber-ruby.git' (including cucumber-expressions 5.0.17) everything is green 👍

@xtrasimplicity
Copy link
Member

Brilliant, thanks for confirming that, @langalex!

@langalex
Copy link
Author

@xtrasimplicity thanks for putting in the time!

@xtrasimplicity
Copy link
Member

Not a problem. I'll close this one off for the moment as it will be resolved with the release of 3.1.1. :)

@aslakhellesoy
Copy link
Contributor

@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.

@xtrasimplicity
Copy link
Member

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?

@aslakhellesoy
Copy link
Contributor

Yes please

@langalex
Copy link
Author

@aslakhellesoy sure

@aslakhellesoy
Copy link
Contributor

@langalex bundle exec cucumber passes for me in that repo. Are you seeing something else?

@langalex
Copy link
Author

@aslakhellesoy well, it does fail on travis. I ran bundle exec cucumber features/test.feature but same with just bundle exec cucumber.

@langalex
Copy link
Author

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.

@aslakhellesoy
Copy link
Contributor

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.

@alexbaranovskyi
Copy link

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.

@xtrasimplicity
Copy link
Member

Thanks for investigating this, @alexbaranovskyi!

@xtrasimplicity
Copy link
Member

xtrasimplicity commented May 24, 2018

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'

@stale
Copy link

stale bot commented Jul 23, 2018

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.

@stale stale bot added the ⌛ stale Will soon be closed by stalebot unless there is activity label Jul 23, 2018
@langalex
Copy link
Author

I say this is fixed and can be closed.

@stale stale bot removed the ⌛ stale Will soon be closed by stalebot unless there is activity label Jul 23, 2018
@xtrasimplicity
Copy link
Member

Thanks, @langalex!

@lock
Copy link

lock bot commented Jul 23, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants