diff --git a/vendor/plugins/coulda/features/feature_generator.feature b/vendor/plugins/coulda/features/feature_generator.feature index c6d8b4d..3c8063f 100644 --- a/vendor/plugins/coulda/features/feature_generator.feature +++ b/vendor/plugins/coulda/features/feature_generator.feature @@ -8,7 +8,7 @@ Feature: Rails controller generator And the coulda plugin is installed When I generate a "new" feature for "Posts" Then a "posts" feature for the "create" scenario should be generated - And a "posts" step definition should be generated + And a "create posts" step definition should be generated And a new post page path should be generated Scenario: Feature generator for create action same as new @@ -16,6 +16,22 @@ Feature: Rails controller generator And the coulda plugin is installed When I generate a "create" feature for "Posts" Then a "posts" feature for the "create" scenario should be generated - And a "posts" step definition should be generated + And a "create posts" step definition should be generated And a new post page path should be generated + Scenario: Feature generator for edit action + Given a Rails app with Cucumber + And the coulda plugin is installed + When I generate a "edit" feature for "Posts" + Then a "posts" feature for the "edit" scenario should be generated + And a "update posts" step definition should be generated + And a edit post page path should be generated + + Scenario: Feature generator for update action same as edit + Given a Rails app with Cucumber + And the coulda plugin is installed + When I generate a "update" feature for "Posts" + Then a "posts" feature for the "update" scenario should be generated + And a "update posts" step definition should be generated + And a edit post page path should be generated + diff --git a/vendor/plugins/coulda/features/step_definitions/cucumber_steps.rb b/vendor/plugins/coulda/features/step_definitions/cucumber_steps.rb index df0e8ba..9e83ae6 100644 --- a/vendor/plugins/coulda/features/step_definitions/cucumber_steps.rb +++ b/vendor/plugins/coulda/features/step_definitions/cucumber_steps.rb @@ -19,10 +19,17 @@ Then /^a "posts" feature for the "([^\"]*)" scenario should be generated$/ do |a " When I create a post named \"A new post\"\n" << " Then I should see \"A new post\"" end + elsif %w(edit update).include?(action) + assert_generated_file("features/posts.feature") do + " Scenario: Update a post\n" << + " Given I am on the edit \"An existing post\" post page\n" << + " When I update the post\n" << + " Then I should see \"Post updated\"" + end end end -Then /^a "posts" step definition should be generated$/ do +Then /^a "create posts" step definition should be generated$/ do assert_generated_file("features/step_definitions/posts_steps.rb") do "When /^I create a post named \"([^\\\"]*)\"$/ do |name|\n" << " fills_in :name, :with => name\n" << @@ -38,3 +45,20 @@ Then /^a new post page path should be generated$/ do end end +Then /^a "update posts" step definition should be generated$/ do + assert_generated_file("features/step_definitions/posts_steps.rb") do + "When /^I update a post named \"([^\\\"]*)\"$/ do |name|\n" << + " fills_in :name, :with => name\n" << + " click_button 'Update'\n" + "end" + end +end + +Then /^a edit post page path should be generated$/ do + assert_generated_file("features/support/paths.rb") do + " when /the edit \"([^\\\"]*)\" post page/i do |name|\n" << + " post = Post.find_by_name(name)\n" + " edit_post_path(post)" + end +end + diff --git a/vendor/plugins/coulda/generators/feature/feature_generator.rb b/vendor/plugins/coulda/generators/feature/feature_generator.rb index 785f18b..da28bd1 100644 --- a/vendor/plugins/coulda/generators/feature/feature_generator.rb +++ b/vendor/plugins/coulda/generators/feature/feature_generator.rb @@ -22,6 +22,10 @@ class FeatureGenerator < Rails::Generator::NamedBase if %w(new create).any? { |action| actions.include?(action) } " when /the new #{resource} page/i\n" << " new_#{resource}_path\n" + elsif %w(edit update).any? { |action| actions.include?(action) } + " when /the edit \"([^\\\"]*)\" #{resource} page/i do |name|\n" << + " post = #{resource_class}.find_by_name(name)\n" + " edit_#{resource}_path(#{resource})" end end end diff --git a/vendor/plugins/coulda/generators/feature/templates/feature.feature b/vendor/plugins/coulda/generators/feature/templates/feature.feature index fb72b06..5d6b1f5 100644 --- a/vendor/plugins/coulda/generators/feature/templates/feature.feature +++ b/vendor/plugins/coulda/generators/feature/templates/feature.feature @@ -3,4 +3,9 @@ Given I am on the new <%= resource %> page When I create a <%= resource %> named "A new <%= resource %>" Then I should see "A new <%= resource %>" +<% elsif %w(edit update).any? { |action| actions.include?(action) } -%> + Scenario: Update a <%= resource %> + Given I am on the edit "An existing <%= resource %>" <%= resource %> page + When I update the <%= resource %> + Then I should see "<%= resource_class %> updated" <% end -%> diff --git a/vendor/plugins/coulda/generators/feature/templates/step_definition.rb b/vendor/plugins/coulda/generators/feature/templates/step_definition.rb index a0006b7..78572d3 100644 --- a/vendor/plugins/coulda/generators/feature/templates/step_definition.rb +++ b/vendor/plugins/coulda/generators/feature/templates/step_definition.rb @@ -1,4 +1,12 @@ +<% if %w(new create).any? { |action| actions.include?(action) } -%> When /^I create a <%= resource %> named "([^\"]*)"$/ do |name| fills_in :name, :with => name click_button 'Create' end +<% elsif %w(edit update).any? { |action| actions.include?(action) } -%> +When /^I update a post named "([^\"]*)"$/ do |name| + fills_in :name, :with => name + click_button 'Update' +end +<% end -%> + diff --git a/vendor/plugins/coulda/generators/support/insert_commands.rb b/vendor/plugins/coulda/generators/support/insert_commands.rb index 753c763..ce4edc0 100644 --- a/vendor/plugins/coulda/generators/support/insert_commands.rb +++ b/vendor/plugins/coulda/generators/support/insert_commands.rb @@ -1,4 +1,4 @@ -# Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master +# Pinched some from http://github.com/ryanb/nifty-generators Rails::Generator::Commands::Base.class_eval do def file_contains?(relative_destination, line) -- libgit2 0.21.2