Skip to content

Commit

Permalink
fix steps which can only be used once per scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Enceradeira authored and mattwynne committed Dec 23, 2022
1 parent 7736080 commit 3d6fcf4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions features/lib/step_definitions/scenarios_and_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ def snake_case(name)
Given('a scenario {string} that passes') do |name|
create_feature(name) do
create_scenario(name) do
' Given it passes'
" Given it passes in #{name}"
end
end

write_file(
"features/step_definitions/#{name}_steps.rb",
step_definition('/^it passes$/', 'expect(true).to be true')
step_definition("/^it passes in #{name}$/", 'expect(true).to be true')
)
end

Given('a scenario {string} that fails') do |name|
create_feature(name) do
create_scenario(name) do
' Given it fails'
" Given it fails in #{name}"
end
end

write_file(
"features/step_definitions/#{name}_steps.rb",
step_definition('/^it fails$/', 'expect(false).to be true')
step_definition("/^it fails in #{name}$/", 'expect(false).to be true')
)
end

Expand All @@ -58,14 +58,14 @@ def snake_case(name)

create_feature("#{full_name} feature") do
create_scenario(full_name) do
' Given it fails once, then passes'
" Given it fails once, then passes in #{full_name}"
end
end

write_file(
"features/step_definitions/#{name}_steps.rb",
step_definition(
'/^it fails once, then passes$/',
"/^it fails once, then passes in #{full_name}$/",
[
"$#{name} += 1",
"expect($#{name}).to be > 1"
Expand All @@ -84,14 +84,14 @@ def snake_case(name)

create_feature("#{full_name} feature") do
create_scenario(full_name) do
' Given it fails twice, then passes'
" Given it fails twice, then passes in #{full_name}"
end
end

write_file(
"features/step_definitions/#{name}_steps.rb",
step_definition(
'/^it fails twice, then passes$/',
"/^it fails twice, then passes in #{full_name}$/",
[
"$#{name} ||= 0",
"$#{name} += 1",
Expand Down

0 comments on commit 3d6fcf4

Please sign in to comment.