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

Step name incorrect when multiple backslashes in Examples block #1006

Closed
paoloambrosio-skyuk opened this Issue Aug 17, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@paoloambrosio-skyuk

paoloambrosio-skyuk commented Aug 17, 2016

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

This comment has been minimized.

Show comment
Hide comment
@paoloambrosio

paoloambrosio Aug 17, 2016

Member

Sorry, submitted this with the work account :-)

Member

paoloambrosio commented Aug 17, 2016

Sorry, submitted this with the work account :-)

@paoloambrosio paoloambrosio referenced this issue Aug 25, 2016

Merged

Issue79 #116

@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot 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 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 label Nov 8, 2017

@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot Nov 15, 2017

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

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 Nov 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment