cucumber/cucumber — Issue #171: Failing to parse steps with steps %Q{ ... }
Author: farcaller
Created: 2011-11-09 15:12:57+00:00
State: open

having a scenario:

Scenario: successfully log in with existing account using login
Given there is user "testuser" registered with email "test@user.net"
When I sign in with "testuser" and password "helloworld"
Then I should see account menu for "test@user.net"
And I should see a flash message stating that login is successful

And steps:

When /^I click on link "([^"]*)"$/ do |link|
click_on link
end

When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, data|
fill_in field, :with => data
end

When /^I click on button "([^"]*)"$/ do |button|
click_button button
end

The following step works:

When /^I register with username "([^"]*)" and email "([^"]*)"$/ do |username, email|
step %Q{I click on link "Sign up"}
step %Q{I fill in "Username" with "#{username}"}
step %Q{I fill in "Email" with "#{email}"}
step %Q{I fill in "Password" with "123456"}
step %Q{I fill in "Confirm Password" with "123456"}
step %Q{I click on button "Sign up"}
end

But this one fails:

When /^I register with username "([^"]*)" and email "([^"]*)"$/ do |username, email|
steps %Q{
I click on link "Sign up"
I fill in "Username" with "#{username}"
I fill in "Email" with "#{email}"
I fill in "Password" with "123456"
I fill in "Confirm Password" with "123456"
I click on button "Sign up"
}
end

with errors like:

When I register with username "testuser" and email "test@user.net" # features/step_definitions/user_steps.rb:4
Lexing error on line 2: ' I click on link "Sign up"'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information. (Gherkin::Lexer::LexingError)
./features/step_definitions/user_steps.rb:12:in `/^I register with username "([^"]*)" and email "([^"]*)"$/'
features/user_registers.feature:12:in `When I register with username "testuser" and email "test@user.net"'