From 43dac6a62f05feaa88f00adc665f43f4d3ffd4fb Mon Sep 17 00:00:00 2001 From: Dana Scheider Date: Mon, 19 Oct 2015 11:29:31 -0700 Subject: [PATCH] Define steps for the retry feature --- .../lib/step_definitions/cucumber_steps.rb | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/features/lib/step_definitions/cucumber_steps.rb b/features/lib/step_definitions/cucumber_steps.rb index 3a70db6450..9eaeea66e4 100644 --- a/features/lib/step_definitions/cucumber_steps.rb +++ b/features/lib/step_definitions/cucumber_steps.rb @@ -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