Skip to content

Use single quotes in generated template steps #1323

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

Merged
merged 1 commit into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions features/docs/defining_steps/snippets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ Feature: Snippets
When I run `cucumber features/undefined_steps.feature -s`
Then the output should contain:
"""
Given("a Doc String") do |string|
Given('a Doc String') do |string|
pending # Write code here that turns the phrase above into concrete actions
end

When("{int} simple when step") do |int|
When('{int} simple when step') do |int|
pending # Write code here that turns the phrase above into concrete actions
end

When("another {string} step") do |string|
When('another {string} step') do |string|
pending # Write code here that turns the phrase above into concrete actions
end

Then("a simple then step") do
Then('a simple then step') do
pending # Write code here that turns the phrase above into concrete actions
end
"""
Expand All @@ -49,7 +49,7 @@ Feature: Snippets
When I run `cucumber features/undefined_steps.feature -s`
Then the output should contain:
"""
Given("a table") do |table|
Given('a table') do |table|
# table is a Cucumber::MultilineArgument::DataTable
pending # Write code here that turns the phrase above into concrete actions
end
Expand Down
6 changes: 3 additions & 3 deletions features/docs/formatters/usage_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ Feature: Usage formatter
"""
You can implement step definitions for undefined steps with these snippets:

When("I add {int} and {int}") do |int, int2|
When('I add {int} and {int}') do |int, int2|
pending # Write code here that turns the phrase above into concrete actions
end

Then("I should get {int}") do |int|
Then('I should get {int}') do |int|
pending # Write code here that turns the phrase above into concrete actions
end
"""
"""
2 changes: 1 addition & 1 deletion features/docs/gherkin/using_star_notation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Feature: Using star notation instead of Given/When/Then
"""
You can implement step definitions for undefined steps with these snippets:

Given("I have some cukes") do
Given('I have some cukes') do
pending # Write code here that turns the phrase above into concrete actions
end
"""
2 changes: 1 addition & 1 deletion lib/cucumber/glue/snippet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def typed_pattern
def to_s
header = generated_expressions.each_with_index.map do |expr, i|
prefix = i.zero? ? '' : '# '
"#{prefix}#{code_keyword}(\"#{expr.source}\") do#{parameters(expr)}"
"#{prefix}#{code_keyword}('#{expr.source}') do#{parameters(expr)}"
end.join("\n")

body = String.new # rubocop:disable Style/EmptyLiteral
Expand Down
28 changes: 14 additions & 14 deletions spec/cucumber/formatter/pretty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -860,12 +860,12 @@ module Formatter
FEATURE

it "containes snippets with 'And' or 'But' replaced by previous step name" do
expect(@out.string).to include('Given("there are bananas and apples")')
expect(@out.string).to include('Given("other monkeys are around")')
expect(@out.string).to include('When("one monkey eats a banana")')
expect(@out.string).to include('When("the other monkeys eat all the apples")')
expect(@out.string).to include('Then("bananas remain")')
expect(@out.string).to include('Then("there are no apples left")')
expect(@out.string).to include("Given('there are bananas and apples')")
expect(@out.string).to include("Given('other monkeys are around')")
expect(@out.string).to include("When('one monkey eats a banana')")
expect(@out.string).to include("When('the other monkeys eat all the apples')")
expect(@out.string).to include("Then('bananas remain')")
expect(@out.string).to include("Then('there are no apples left')")
end
end

Expand All @@ -882,12 +882,12 @@ module Formatter
* there are no apples left
FEATURE
it "replaces the first step with 'Given'" do
expect(@out.string).to include('Given("there are bananas and apples")')
expect(@out.string).to include("Given('there are bananas and apples')")
end
it "uses actual keywords as the 'previous' keyword for future replacements" do
expect(@out.string).to include('Given("other monkeys are around")')
expect(@out.string).to include('When("the other monkeys eat all the apples")')
expect(@out.string).to include('Then("there are no apples left")')
expect(@out.string).to include("Given('other monkeys are around')")
expect(@out.string).to include("When('the other monkeys eat all the apples')")
expect(@out.string).to include("Then('there are no apples left')")
end
end

Expand All @@ -904,7 +904,7 @@ module Formatter
Given('this step passes') {}
end
it 'uses actual keyword of the previous passing step for the undefined step' do
expect(@out.string).to include('Then("this step is undefined")')
expect(@out.string).to include("Then('this step is undefined')")
end
end

Expand All @@ -924,8 +924,8 @@ module Formatter
Given('this step passes') {}
end
it "uses 'Given' as actual keyword the step in each scenario" do
expect(@out.string).to include('Given("this step is undefined")')
expect(@out.string).to include('Given("this step is also undefined")')
expect(@out.string).to include("Given('this step is undefined')")
expect(@out.string).to include("Given('this step is also undefined')")
end
end

Expand All @@ -939,7 +939,7 @@ module Formatter
AN I EAT CUCUMBRZ
FEATURE
it 'uses actual keyword of the previous passing step for the undefined step' do
expect(@out.string).to include('ICANHAZ("I EAT CUCUMBRZ")')
expect(@out.string).to include("ICANHAZ('I EAT CUCUMBRZ')")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/cucumber/glue/snippet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def unindented(snippet)
))

expect(snippet.to_s).to eq unindented(%{
Given("I have {float} {cucumis} in my belly") do |float, cucumis|
# Given("I have {float} {veg} in my belly") do |float, veg|
Given('I have {float} {cucumis} in my belly') do |float, cucumis|
# Given('I have {float} {veg} in my belly') do |float, veg|
pending # Write code here that turns the phrase above into concrete actions
end
})
Expand Down