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

Wrong step definition created when having "(" #1291

Closed
aslakhellesoy opened this issue Apr 20, 2018 · 14 comments
Closed

Wrong step definition created when having "(" #1291

aslakhellesoy opened this issue Apr 20, 2018 · 14 comments
Assignees

Comments

@aslakhellesoy
Copy link
Contributor

From @christianbaumann on April 19, 2018 9:43

Summary

I have a step definition which contains "(" and ")", eg.

And the room information (room code and availability) is correct

Expected Behavior

When I run cucumber and have no step definition defined, I would expect a matching step definition to be defined

And(/^the room information (room code and availability) is correct$/) do

Current Behavior

Instead, following step definition is created:

And("the room information (room code and availability) is correct") do

Your Environment

  • Ruby: ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
  • Cucumber:
    cucumber (3.1.0)
    cucumber-core (3.1.0)
    cucumber-expressions (5.0.17, 5.0.15)
    cucumber-tag_expressions (1.1.1)
    cucumber-wire (0.0.1)
  • Operating System and version: Windows 8.1 Enterprise

Copied from original issue: cucumber/common#364

@aslakhellesoy
Copy link
Contributor Author

As of 3.0.0.pre.2, cucumber-ruby supports both Cucumber Expressions and Regular Expressions.

Generated snippets use Cucumber Expressions, not Regular Expressions.

I think you may have stumbled upon #333 which should have been fixed by #334, but it looks like there might still be a bug with it.

This needs more investigation....

@aslakhellesoy
Copy link
Contributor Author

@christianbaumann here is a workaround for you. The generated snippet currently is:

Given("the room information \(room code and availability) is correct") do
  pending # Write code here that turns the phrase above into concrete actions
end

Either change double quotes to single quotes:

Given('the room information \(room code and availability) is correct') do
  pending # Write code here that turns the phrase above into concrete actions
end

Or double-escape the opening parenthesis:

Given("the room information \\(room code and availability) is correct") do
  pending # Write code here that turns the phrase above into concrete actions
end

The bug is in cucumber-ruby, and not in cucumber-expressions. We should change the snippet generator to use single quotes rather than double quotes, and only escape single quotes in the expressions itself.

@stale
Copy link

stale bot commented Jul 25, 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 25, 2018
@danascheider
Copy link
Contributor

I'm keeping this open for now but may close it soon and create another PR that uses the double escape instead of single quotes.

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

stale bot commented Sep 25, 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 Sep 25, 2018
@xtrasimplicity
Copy link
Member

Bumping to remove the tag. :)

@stale stale bot removed the ⌛ stale Will soon be closed by stalebot unless there is activity label Sep 26, 2018
@danascheider
Copy link
Contributor

Sorry for the delay on this! It's still on my radar but I'm in the process of moving to Australia so things are particularly hectic atm.

@xtrasimplicity
Copy link
Member

Awesome! All the best with the move! :)

@danascheider
Copy link
Contributor

Question on this @aslakhellesoy (then I'll stop tagging you in stuff for now!): Do we want to accommodate curly braces in step definitions? We could implement this such that Cucumber first looks for a param type with the name in the curly braces and, if it doesn't find one, assumes the curly braces are part of the step. I can think of good reasons for or against this, so I thought I'd ask for your input. @brasmusson, @mattwynne, @tooky - maybe you guys have thoughts on this as well?

@aslakhellesoy
Copy link
Contributor Author

@danascheider I think this bug was (incidentally?) fixed by @acant in #1323.

No need to handle curly braces in a special way - cucumber-expressions handles escaping.

@danascheider
Copy link
Contributor

Sweet!

@aslakhellesoy
Copy link
Contributor Author

Sorry - should have been more explicit. This bug will be fixed when #1323 is merged.

@aslakhellesoy aslakhellesoy reopened this Oct 28, 2018
@aslakhellesoy
Copy link
Contributor Author

Fixed by #1323

@lock
Copy link

lock bot commented Oct 29, 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 Oct 29, 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

Successfully merging a pull request may close this issue.

3 participants