From e1987132506162d89dccc355500ce5401398c0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 20 Jun 2011 07:59:31 +0100 Subject: [PATCH] Make core features pass again --- features/bootstrap.feature | 1 - features/cucumber-features | 2 +- .../cucumber-features/core_steps.rb | 64 +++++++++++++------ 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/features/bootstrap.feature b/features/bootstrap.feature index 65d2c703e1..fe0af15cce 100644 --- a/features/bootstrap.feature +++ b/features/bootstrap.feature @@ -3,7 +3,6 @@ Feature: Bootstrapping a new project As a new cucumber user I want cucumber to give helpful error messages in basic situations - @announce Scenario: running cucumber against a non-existing feature file Given a directory without standard Cucumber project directory structure When I run `cucumber` diff --git a/features/cucumber-features b/features/cucumber-features index 2666d26e87..83ea7b5d06 160000 --- a/features/cucumber-features +++ b/features/cucumber-features @@ -1 +1 @@ -Subproject commit 2666d26e876962a0affd4e914f758a07d7e389c1 +Subproject commit 83ea7b5d0657744adc38e5cd95d2bef1d95be944 diff --git a/features/step_definitions/cucumber-features/core_steps.rb b/features/step_definitions/cucumber-features/core_steps.rb index fee5fad4a9..e649fbf224 100644 --- a/features/step_definitions/cucumber-features/core_steps.rb +++ b/features/step_definitions/cucumber-features/core_steps.rb @@ -16,24 +16,39 @@ def write_feature(feature) write_file("features/a_feature.feature", feature) end - def write_mappings(mappings) - mapping_code = mappings.raw.map do |pattern, result| - erb = ERB.new(<<-EOF, nil, '-') -Given /<%= pattern -%>/ do -<% if result == 'passing' -%> - File.open("<%= step_file(pattern) %>", "w") -<% elsif result == 'pending' -%> - File.open("<%= step_file(pattern) %>", "w") - pending -<% else -%> - File.open("<%= step_file(pattern) %>", "w") - raise "bang!" -<% end -%> -end + def write_passing_mapping(step_name) + erb = ERB.new(<<-EOF, nil, '-') + Given /<%= step_name -%>/ do + # ARUBA_IGNORE_START + File.open("<%= step_file(step_name) %>", "w") + # ARUBA_IGNORE_END + end +EOF + append_to_file("features/step_definitions/some_stepdefs.rb", erb.result(binding)) + end + + def write_pending_mapping(step_name) + erb = ERB.new(<<-EOF, nil, '-') + Given /<%= step_name -%>/ do + # ARUBA_IGNORE_START + File.open("<%= step_file(step_name) %>", "w") + # ARUBA_IGNORE_END + pending + end +EOF + append_to_file("features/step_definitions/some_stepdefs.rb", erb.result(binding)) + end + + def write_failing_mapping(step_name) + erb = ERB.new(<<-EOF, nil, '-') + Given /<%= step_name -%>/ do + # ARUBA_IGNORE_START + File.open("<%= step_file(step_name) %>", "w") + # ARUBA_IGNORE_END + raise "bang!" + end EOF - erb.result(binding) - end.join("\n") - write_file("features/step_definitions/some_stepdefs.rb", mapping_code) + append_to_file("features/step_definitions/some_stepdefs.rb", erb.result(binding)) end def write_calculator_code @@ -153,8 +168,19 @@ def assert_skipped(pattern) write_feature(feature) end -When /^Cucumber executes "([^"]*)" with these step mappings:$/ do |scenario_name, mappings| - write_mappings(mappings) +Given /^the step "([^"]*)" has a passing mapping$/ do |step_name| + write_passing_mapping(step_name) +end + +Given /^the step "([^"]*)" has a pending mapping$/ do |step_name| + write_pending_mapping(step_name) +end + +Given /^the step "([^"]*)" has a failing mapping$/ do |step_name| + write_failing_mapping(step_name) +end + +When /^Cucumber executes the scenario "([^"]*)"$/ do |scenario_name| run_scenario(scenario_name) end