Skip to content

Commit

Permalink
Define steps for the retry feature
Browse files Browse the repository at this point in the history
  • Loading branch information
danascheider committed Oct 19, 2015
1 parent a41a081 commit 43dac6a
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions features/lib/step_definitions/cucumber_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,70 @@
create_step_definition { string }
end

Given /^a scenario "([^\"]*)" that fails once, then passes$/ do |name|
write_file "features/#{name}.feature",
<<-FEATURE
Feature: #{name}
Scenario: #{name}
Given it fails once, then passes
FEATURE

write_file "features/step_defnitions/#{name}_steps.rb",
<<-STEPS
Given(/^it fails once, then passes$/) do
$#{name.downcase} ||= 0
$#{name.downcase} += 1
expect($#{name.downcase}).to eql 2
end
STEPS
end

Given /^a scenario "([^\"]*)" that fails twice, then passes$/ do |name|
write_file "features/#{name}.feature",
<<-FEATURE
Feature: #{name}
Scenario: #{name}
Given it fails twice, then passes
FEATURE

write_file "features/step_definitions/#{name}_steps.rb",
<<-STEPS
Given(/^it fails twice, then passes$/) do
$#{name.downcase} ||= 0
$#{name.downcase} += 1
expect($#{name.downcase}).to eql 3
end
STEPS
end

Given /^a scenario "([^\"]*)" that passes$/ do |name|
write_file "features/#{name}.feature",
<<-FEATURE
Feature: #{name}
Scenario: #{name}
Given it passes
FEATURE

write_file "features/step_definitions/#{name}_steps.rb",
<<-STEPS
Given(/^it passes$/) { expect(true).to be true }
STEPS
end

Given /^a scenario "([^\"]*)" that fails$/ do |name|
write_file "features/#{name}.feature",
<<-FEATURE
Feature: #{name}
Scenario: #{name}
Given it fails
FEATURE

write_file "features/step_definitions/#{name}_steps.rb",
<<-STEPS
Given(/^it fails$/) { expect(false).to be true }
STEPS
end

When /^I run the feature with the (\w+) formatter$/ do |formatter|
expect(features.length).to eq 1
run_feature features.first, formatter
Expand Down

0 comments on commit 43dac6a

Please sign in to comment.