From b3d1e974467cd3e8d81fbfd11fdf19f2409e1bd6 Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Fri, 20 Feb 2009 14:06:11 -0500 Subject: [PATCH] Trying to whittle down the lines of code for 'given' sections of scenarios. --- features/generator/cucumber.feature | 9 +++------ features/generator/directory_layout.feature | 15 +++++---------- features/generator/git.feature | 15 +++++---------- features/generator/rakefile.feature | 12 ++++-------- features/generator/test.feature | 13 ++++--------- features/generator/test_helper.feature | 15 +++++---------- features/placeholder.feature | 5 +++++ features/step_definitions/generator_steps.rb | 8 +++++++- 8 files changed, 38 insertions(+), 54 deletions(-) create mode 100644 features/placeholder.feature diff --git a/features/generator/cucumber.feature b/features/generator/cucumber.feature index 16261174..a362623b 100644 --- a/features/generator/cucumber.feature +++ b/features/generator/cucumber.feature @@ -19,8 +19,7 @@ Feature: generating cucumber stories Scenario: cucumber setup for bacon Given a working directory And I have configured git sanely - And I intend to test with bacon - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a bacon project named 'the-perfect-gem' that is 'zomg, so good' Then 'features/support/env.rb' requires 'test/unit/assertions' And 'features/support/env.rb' sets up features to use test/unit assertions @@ -28,8 +27,7 @@ Feature: generating cucumber stories Scenario: cucumber setup for minitest Given a working directory And I have configured git sanely - And I intend to test with minitest - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a minitest project named 'the-perfect-gem' that is 'zomg, so good' Then 'features/support/env.rb' requires 'mini/test' And 'features/support/env.rb' sets up features to use minitest assertions @@ -37,8 +35,7 @@ Feature: generating cucumber stories Scenario: cucumber setup for rspec Given a working directory And I have configured git sanely - And I intend to test with rspec - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a rspec project named 'the-perfect-gem' that is 'zomg, so good' Then 'features/support/env.rb' requires 'the_perfect_gem' And 'features/support/env.rb' requires 'spec/expectations' diff --git a/features/generator/directory_layout.feature b/features/generator/directory_layout.feature index 5137e67e..e3571bd3 100644 --- a/features/generator/directory_layout.feature +++ b/features/generator/directory_layout.feature @@ -17,8 +17,7 @@ Feature: generated directory layout Scenario: bacon Given a working directory And I have configured git sanely - And I intend to test with bacon - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a bacon project named 'the-perfect-gem' that is 'zomg, so good' Then a directory named 'the-perfect-gem/spec' is created @@ -28,8 +27,7 @@ Feature: generated directory layout Scenario: minitest Given a working directory And I have configured git sanely - And I intend to test with minitest - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a minitest project named 'the-perfect-gem' that is 'zomg, so good' Then a directory named 'the-perfect-gem/test' is created @@ -39,8 +37,7 @@ Feature: generated directory layout Scenario: rspec Given a working directory And I have configured git sanely - And I intend to test with rspec - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a rspec project named 'the-perfect-gem' that is 'zomg, so good' Then a directory named 'the-perfect-gem/spec' is created @@ -50,8 +47,7 @@ Feature: generated directory layout Scenario: shoulda Given a working directory And I have configured git sanely - And I intend to test with shoulda - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a shoulda project named 'the-perfect-gem' that is 'zomg, so good' Then a directory named 'the-perfect-gem/test' is created @@ -61,8 +57,7 @@ Feature: generated directory layout Scenario: testunit Given a working directory And I have configured git sanely - And I intend to test with testunit - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a testunit project named 'the-perfect-gem' that is 'zomg, so good' Then a directory named 'the-perfect-gem/test' is created diff --git a/features/generator/git.feature b/features/generator/git.feature index 351a953d..bcfdad20 100644 --- a/features/generator/git.feature +++ b/features/generator/git.feature @@ -38,8 +38,7 @@ Feature: git support Scenario: bacon Given a working directory And I have configured git sanely - And I intend to test with bacon - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a bacon project named 'the-perfect-gem' that is 'zomg, so good' Then 'spec/spec_helper.rb' was checked in And 'spec/the_perfect_gem_spec.rb' was checked in @@ -47,8 +46,7 @@ Feature: git support Scenario: minitest Given a working directory And I have configured git sanely - And I intend to test with minitest - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a minitest project named 'the-perfect-gem' that is 'zomg, so good' Then 'test/test_helper.rb' was checked in And 'test/the_perfect_gem_test.rb' was checked in @@ -56,8 +54,7 @@ Feature: git support Scenario: rspec Given a working directory And I have configured git sanely - And I intend to test with rspec - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a rspec project named 'the-perfect-gem' that is 'zomg, so good' Then 'spec/spec_helper.rb' was checked in And 'spec/the_perfect_gem_spec.rb' was checked in @@ -65,8 +62,7 @@ Feature: git support Scenario: shoulda Given a working directory And I have configured git sanely - And I intend to test with shoulda - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a shoulda project named 'the-perfect-gem' that is 'zomg, so good' Then 'test/test_helper.rb' was checked in And 'test/the_perfect_gem_test.rb' was checked in @@ -74,8 +70,7 @@ Feature: git support Scenario: testunit Given a working directory And I have configured git sanely - And I intend to test with testunit - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a testunit project named 'the-perfect-gem' that is 'zomg, so good' Then 'test/test_helper.rb' was checked in And 'test/the_perfect_gem_test.rb' was checked in diff --git a/features/generator/rakefile.feature b/features/generator/rakefile.feature index 3c1744e0..2fdf7f36 100644 --- a/features/generator/rakefile.feature +++ b/features/generator/rakefile.feature @@ -26,8 +26,7 @@ Feature: generated Rakefile Scenario: minitest Given a working directory And I have configured git sanely - And I intend to test with minitest - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a minitest project named 'the-perfect-gem' that is 'zomg, so good' Then Rakefile has 'test/**/*_test.rb' in the Rake::TestTask pattern And Rakefile has 'test/**/*_test.rb' in the Rcov::RcovTask test_pattern @@ -36,16 +35,14 @@ Feature: generated Rakefile Scenario: rspec Given a working directory And I have configured git sanely - And I intend to test with rspec - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a rspec project named 'the-perfect-gem' that is 'zomg, so good' Then Rakefile has 'spec/**/*_spec.rb' in the Spec::Rake::SpecTask pattern Scenario: shoulda Given a working directory And I have configured git sanely - And I intend to test with shoulda - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a shoulda project named 'the-perfect-gem' that is 'zomg, so good' Then Rakefile has 'test/**/*_test.rb' in the Rake::TestTask pattern And Rakefile has 'test/**/*_test.rb' in the Rcov::RcovTask test_pattern @@ -54,8 +51,7 @@ Feature: generated Rakefile Scenario: testunit Given a working directory And I have configured git sanely - And I intend to test with testunit - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a testunit project named 'the-perfect-gem' that is 'zomg, so good' Then Rakefile has 'test/**/*_test.rb' in the Rake::TestTask pattern And Rakefile has 'test/**/*_test.rb' in the Rcov::RcovTask test_pattern diff --git a/features/generator/test.feature b/features/generator/test.feature index f82ed1bc..90f20bdd 100644 --- a/features/generator/test.feature +++ b/features/generator/test.feature @@ -6,22 +6,19 @@ Feature: generated test or spec Scenario: bacon Given a working directory And I have configured git sanely - And I intend to test with bacon - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a bacon project named 'the-perfect-gem' that is 'zomg, so good' Then 'spec/the_perfect_gem_spec.rb' should describe 'ThePerfectGem' Scenario: minitest Given a working directory And I have configured git sanely - And I intend to test with minitest - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a minitest project named 'the-perfect-gem' that is 'zomg, so good' Then 'test/the_perfect_gem_test.rb' should define 'ThePerfectGemTest' as a subclass of 'Mini::Test::TestCase' Scenario: rspec Given a working directory And I have configured git sanely - And I intend to test with rspec - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a rspec project named 'the-perfect-gem' that is 'zomg, so good' Then 'spec/the_perfect_gem_spec.rb' should describe 'ThePerfectGem' Scenario: shoulda @@ -34,7 +31,5 @@ Feature: generated test or spec Scenario: testunit Given a working directory And I have configured git sanely - And I intend to test with testunit - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a testunit project named 'the-perfect-gem' that is 'zomg, so good' Then 'test/the_perfect_gem_test.rb' should define 'ThePerfectGemTest' as a subclass of 'Test::Unit::TestCase' - diff --git a/features/generator/test_helper.feature b/features/generator/test_helper.feature index 4696c0b9..60711b8a 100644 --- a/features/generator/test_helper.feature +++ b/features/generator/test_helper.feature @@ -6,16 +6,14 @@ Feature: generated test or spec Scenario: bacon Given a working directory And I have configured git sanely - And I intend to test with bacon - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a bacon project named 'the-perfect-gem' that is 'zomg, so good' Then 'spec/spec_helper.rb' requires 'bacon' And 'spec/spec_helper.rb' requires 'the_perfect_gem' Scenario: minitest Given a working directory And I have configured git sanely - And I intend to test with minitest - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a minitest project named 'the-perfect-gem' that is 'zomg, so good' Then 'test/test_helper.rb' requires 'mini/test' And 'test/test_helper.rb' requires 'the_perfect_gem' And 'test/test_helper.rb' should autorun tests @@ -23,16 +21,14 @@ Feature: generated test or spec Scenario: rspec Given a working directory And I have configured git sanely - And I intend to test with rspec - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a rspec project named 'the-perfect-gem' that is 'zomg, so good' Then 'spec/spec_helper.rb' requires 'spec' And 'spec/spec_helper.rb' requires 'the_perfect_gem' Scenario: shoulda Given a working directory And I have configured git sanely - And I intend to test with shoulda - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a shoulda project named 'the-perfect-gem' that is 'zomg, so good' Then 'test/test_helper.rb' requires 'test/unit' And 'test/test_helper.rb' requires 'shoulda' And 'test/test_helper.rb' requires 'mocha' @@ -41,8 +37,7 @@ Feature: generated test or spec Scenario: testunit Given a working directory And I have configured git sanely - And I intend to test with testunit - When I generate a project named 'the-perfect-gem' that is 'zomg, so good' + When I generate a testunit project named 'the-perfect-gem' that is 'zomg, so good' Then 'test/test_helper.rb' requires 'test/unit' And 'test/test_helper.rb' requires 'mocha' And 'test/test_helper.rb' requires 'the_perfect_gem' diff --git a/features/placeholder.feature b/features/placeholder.feature new file mode 100644 index 00000000..e323d3e5 --- /dev/null +++ b/features/placeholder.feature @@ -0,0 +1,5 @@ +Feature: I am a placeholder + + Scenario: I am also a placeholder + Given a working directory + diff --git a/features/step_definitions/generator_steps.rb b/features/step_definitions/generator_steps.rb index 0b1892cf..91d49bb5 100644 --- a/features/step_definitions/generator_steps.rb +++ b/features/step_definitions/generator_steps.rb @@ -24,10 +24,16 @@ -When /^I generate a project named '((?:\w|-|_)+)' that is '(.*)'$/ do |name, summary| +When /^I generate a (.*)project named '((?:\w|-|_)+)' that is '(.*)'$/ do |testing_framework, name, summary| @name = name @summary = summary + testing_framework = testing_framework.squeeze.strip + unless testing_framework.blank? + @testing_framework = testing_framework.to_sym + end + + @generator = Jeweler::Generator.new(@name, :directory => "#{@working_dir}/#{@name}", :summary => @summary,