Skip to content

Step name incorrect when multiple backslashes in Examples block #1006

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

Closed
paoloambrosio-skyuk opened this issue Aug 17, 2016 · 4 comments
Closed
Labels
⌛ stale Will soon be closed by stalebot unless there is activity

Comments

@paoloambrosio-skyuk
Copy link

Summary

Step name is incorrect when multiple backslashes are present in the Examples block.

Expected Behavior

The step name should be obtained by just filling the placeholders with the values in the Examples block

The only escaping should be that defined by the Gherkin grammar:

The \-character will be considered as an escape in table cell iff it is followed by a |-character, a \-character or an n.

I would expect this feature to pass:

Feature: Escaping

  Scenario Outline:
    * '<a>' should equal '|'
    * '<b>' should equal '\\\+'
    * '<c>' should equal '\\\\\\'

    Examples:
      | a  | b       | c            |
      | \| | \\\\\\+ | \\\\\\\\\\\\ |

If run with this step definition:

Given(/^'([^']*)' should equal '([^']*)'$/) do |x,y|
  x.should == y
end

The same feature passes if run with Cucumber-JVM and this step definition:

@Given("^'([^']*)' should equal '([^']*)'$")
public void checkEquality(String x, String y) {
    assertEquals(y, x);
}

Current Behavior

It fails on the second step with:

      expected: "\\\\\\+"
           got: "\\" (using ==) (RSpec::Expectations::ExpectationNotMetError)
      ./features/step_definitions/escaping.rb:6:in `/^'([^']*)' should equal '([^']*)'$/'
      features/escaping.feature:10:in `* '\' should equal '\\\+''
      features/escaping.feature:5:in `* '<b>' should equal '\\\+''

By printing the step name in an AfterStep hook, the above Scenario Outline gets expanded to:

Feature: Escaping

  Scenario Outline:
    * '|' should equal '|'
    * '\' should equal '\\\+'
    * '\\\' should equal '\\\\\\'

Possible Solution

Escaping seems to be correct in the Gherkin parser (at least 4.0.0). The same issue is present at least from version 1.3.20 to the latest 2.4.0, so it's probably not a parser problem. No idea where to look in Cucumber-Ruby.

Steps to Reproduce (for bugs)

  1. Create a feature file and a step definition file as described in the "Expected Behavior" section
  2. Run Cucumber-Ruby

Context & Motivation

Was writing scenarios to test regex escaping in the snippets generation of Cucumber-CPP, that still uses Cucumber-Ruby and Aruba for E2E testing.

Your Environment

  • Version used: 1.3.20 (gherkin 2.12.2), 2.0.0 (gherkin 2.12.2), 2.4.0 (gherkin 4.0.0)
  • Operating System and version: OSX 10.11.6, Ruby 2.3.0 with RVM
@paoloambrosio
Copy link
Member

Sorry, submitted this with the work account :-)

@stale
Copy link

stale bot commented Nov 8, 2017

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 Nov 8, 2017
@stale
Copy link

stale bot commented Nov 15, 2017

This issue has been automatically closed because of inactivity. You can support the Cucumber core team on opencollective.

@stale stale bot closed this as completed Nov 15, 2017
@lock
Copy link

lock bot commented Nov 15, 2018

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 Nov 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⌛ stale Will soon be closed by stalebot unless there is activity
Projects
None yet
Development

No branches or pull requests

2 participants