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

Rake task fails with composite tag value option #1614

Closed
sashaCher opened this issue Feb 8, 2022 · 4 comments · Fixed by #1624
Closed

Rake task fails with composite tag value option #1614

sashaCher opened this issue Feb 8, 2022 · 4 comments · Fixed by #1624

Comments

@sashaCher
Copy link

sashaCher commented Feb 8, 2022

Describe the bug

When cucumber rake task cucumber_opts field is a string and it contains composite tag option like --tags 'not @skip' cucumber rake task fails with No such file or directory - @skip'. You can use cucumber --init to get started. error.

To Reproduce
Steps to reproduce the behavior:

  1. Create new cucumber rake task like this
    desc 'Run features'
    Cucumber::Rake::Task.new(:features) do |t|
      t.cucumber_opts = "--tag 'not @skip'"
    end
    task :cucumber => :features
    Where cucumber_opts task property is set to a string value ends by composite tag option, `` for example
  2. Run the rake task bundle exec rake cucumber
  3. See error: No such file or directory - @skip'. You can use `cucumber --init`

Expected behavior

The rake task is running scenarios meets chosen tags criteria.
In the above example all scenarios except having @skip tag will run.

Additional context

Looks like the next split is a root cause of the issue:

@cucumber_opts = String == opts.class ? opts.split(' ') : opts

@valerianb
Copy link
Contributor

The preferred type is an array.

It should work fine if you pass:

t.cucumber_opts = ["--tag", "'not @skip'"]

@sashaCher
Copy link
Author

Thank you @valerianb!
It's definitely worked.
I guess more strict approach to parameters validation/warning that preferred type is an array was able to save me couple hours of frustration after cucumber gem upgrade.

@aurelien-reeves
Copy link
Contributor

Do you have ideas on how to improve things on that area?

The cucumber_opts has always worked that way and has always been documented as being better used with arrays rather than strings.

What changed with cucumber v4 more than 3 years ago now is the removal of the old syntax for tag expressions. Tag expressions can have space in it. I guess this is what caused your issue.

However changing support of strings for cucumber_opts in rake task would actually be a breaking change for a well known and documented feature. Would you have ideas to avoid such a breaking change? Are there some documentation in some places that may be updated to emphasize more the use of arrays rather than strings?

@sashaCher
Copy link
Author

I guess that a warning that string type cucumber_opts does not support all options and it's recommended to use array type will improve troubleshooting around the code area.
Exactly like warning about ~ replacement by not was/is.
I've found also another example in the repo supports this approach

$stderr.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")

In my case I upgraded cucumber to version 7 and then ~ negation started throw an exception. Good, actually, exception with explanation what I need to do: to replace it by not. But replacing by not threw other exception, that it was quite hard to figure out what's a root cause of it.

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 a pull request may close this issue.

3 participants