diff --git a/vendor/plugins/coulda/features/controller_generator.feature b/vendor/plugins/coulda/features/controller_generator.feature
index 86fe696..22575b9 100644
--- a/vendor/plugins/coulda/features/controller_generator.feature
+++ b/vendor/plugins/coulda/features/controller_generator.feature
@@ -27,6 +27,14 @@ Feature: Rails controller generator
And a "create" controller action for "posts" should be generated
And only a "create" action for RESTful "posts" route should be generated
+ Scenario: Controller generator for create action when Cucumber is installed
+ Given a Rails app with Cucumber
+ And the coulda plugin is installed
+ When I generate a "Posts" controller with "create" action
+ Then a standard "create" functional test for "posts" should be generated
+ And a "create" controller action for "posts" should be generated
+ And only a "create" action for RESTful "posts" route should be generated
+
Scenario: Controller generator for show action
Given a Rails app
And the coulda plugin is installed
diff --git a/vendor/plugins/coulda/features/step_definitions/controller_steps.rb b/vendor/plugins/coulda/features/step_definitions/controller_steps.rb
index be7a321..b76a533 100644
--- a/vendor/plugins/coulda/features/step_definitions/controller_steps.rb
+++ b/vendor/plugins/coulda/features/step_definitions/controller_steps.rb
@@ -35,7 +35,6 @@ Then /^a standard "create" functional test for "posts" should be generated$/ do
" setup do\n" <<
" post :create, :post => Factory.attributes_for(:post)\n" <<
" end\n\n" <<
- " should_create :post\n" <<
" should_set_the_flash_to /created/i\n" <<
" should_redirect_to('posts index') { posts_path }\n" <<
" end"
diff --git a/vendor/plugins/coulda/features/step_definitions/cucumber_steps.rb b/vendor/plugins/coulda/features/step_definitions/cucumber_steps.rb
new file mode 100644
index 0000000..98c80cb
--- /dev/null
+++ b/vendor/plugins/coulda/features/step_definitions/cucumber_steps.rb
@@ -0,0 +1,21 @@
+Given /^a Rails app with Cucumber$/ do
+ system "rails rails_root"
+ @rails_root = File.join(File.dirname(__FILE__), "..", "..", "rails_root")
+ require 'cucumber'
+end
+
+Then /^a Cucumber "([^\"]*)" functional test for "([^\"]*)" should be generated$/ do |arg1, arg2|
+ pending
+end
+
+Then /^a standard "posts" feature for the "new" scenario should be generated$/ do
+ assert_generated_file("features/posts.feature") do |body|
+ expected = " Scenario: Create a new 'post'\n" <<
+ " Given I am on the new post page\n" <<
+ " When I create a 'post' named 'A new post'\n" <<
+ " Then I should see 'A new post'"
+ assert body.include?(expected),
+ "expected #{expected} but was #{body.inspect}"
+ end
+end
+
diff --git a/vendor/plugins/coulda/features/step_definitions/view_steps.rb b/vendor/plugins/coulda/features/step_definitions/view_steps.rb
index 24db4c2..2a47dec 100644
--- a/vendor/plugins/coulda/features/step_definitions/view_steps.rb
+++ b/vendor/plugins/coulda/features/step_definitions/view_steps.rb
@@ -1,4 +1,18 @@
-Then /^an empty "(.*)" view for "(.*)" should be generated$/ do |action, controller|
- assert_generated_views_for(controller, action)
+When /^I generate a "([^\"]*)" view for "([^\"]*)"$/ do |view, resource|
+ system "cd #{@rails_root} && " <<
+ "script/generate view #{resource} #{view} && " <<
+ "cd .."
+end
+
+When /^a standard "new" view for "posts" should be generated$/ do
+ assert_generated_file("app/views/posts/new.html.erb") do |body|
+ expected = "
New post
\n\n" <<
+ "<% form_for(@post) do |form| %>\n" <<
+ " <%= form.error_messages %>\n" <<
+ " <%= form.submit 'Create', :disable_with => 'Please wait...' %>\n" <<
+ "<% end %>"
+ assert body.include?(expected),
+ "expected #{expected} but was #{body.inspect}"
+ end
end
diff --git a/vendor/plugins/coulda/features/view_generator.feature b/vendor/plugins/coulda/features/view_generator.feature
new file mode 100644
index 0000000..19a8c3b
--- /dev/null
+++ b/vendor/plugins/coulda/features/view_generator.feature
@@ -0,0 +1,12 @@
+Feature: Rails controller generator
+ In order to better do Test-Driven Development with Rails
+ As a user
+ I want to generate Shoulda & Factory Girl tests for only RESTful actions I need.
+
+ Scenario: View generator for new action when Cucumber is installed
+ Given a Rails app with Cucumber
+ And the coulda plugin is installed
+ When I generate a "new" view for "Posts"
+ Then a standard "new" view for "posts" should be generated
+ And a standard "posts" feature for the "new" scenario should be generated
+
diff --git a/vendor/plugins/coulda/generators/controller/templates/functional_test.rb b/vendor/plugins/coulda/generators/controller/templates/functional_test.rb
index 702bd9f..8df1d42 100644
--- a/vendor/plugins/coulda/generators/controller/templates/functional_test.rb
+++ b/vendor/plugins/coulda/generators/controller/templates/functional_test.rb
@@ -30,7 +30,6 @@ class <%= class_name %>ControllerTest < ActionController::TestCase
post :create, :<%= resource %> => Factory.attributes_for(:<%= resource %>)
end
- should_create :<%= resource %>
should_set_the_flash_to /created/i
should_redirect_to('<%= resources %> index') { <%= resources %>_path }
end
diff --git a/vendor/plugins/coulda/generators/view/templates/feature.feature b/vendor/plugins/coulda/generators/view/templates/feature.feature
new file mode 100644
index 0000000..5a71b7e
--- /dev/null
+++ b/vendor/plugins/coulda/generators/view/templates/feature.feature
@@ -0,0 +1,10 @@
+<% resource = file_name.singularize -%>
+<% resources = file_name.pluralize -%>
+<% resource_class = class_name.singularize -%>
+
+<% if %w(new create).any? { |action| actions.include?(action) } -%>
+ Scenario: Create a new '<%= resource %>'
+ Given I am on the new <%= resource %> page
+ When I create a '<%= resource %>' named 'A new <%= resource %>'
+ Then I should see 'A new <%= resource %>'
+<% end -%>
diff --git a/vendor/plugins/coulda/generators/view/templates/view_new.html.erb b/vendor/plugins/coulda/generators/view/templates/view_new.html.erb
index ec9e61d..52b89ac 100644
--- a/vendor/plugins/coulda/generators/view/templates/view_new.html.erb
+++ b/vendor/plugins/coulda/generators/view/templates/view_new.html.erb
@@ -1,6 +1,7 @@
-New <%= singular_name %>
+<% resource = file_name.singularize -%>
+New <%= resource %>
-<%% form_for(@<%= singular_name %>) do |form| %>
+<%% form_for(@<%= resource %>) do |form| %>
<%%= form.error_messages %>
- <%%= form.submit "Create", :disable_with => "Please wait..." %>
+ <%%= form.submit 'Create', :disable_with => 'Please wait...' %>
<%% end %>
diff --git a/vendor/plugins/coulda/generators/view/templates/view_show.html.erb b/vendor/plugins/coulda/generators/view/templates/view_show.html.erb
new file mode 100644
index 0000000..3393646
--- /dev/null
+++ b/vendor/plugins/coulda/generators/view/templates/view_show.html.erb
@@ -0,0 +1,4 @@
+<%= singular_name %>
+
+<%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %>
+
diff --git a/vendor/plugins/coulda/generators/view/view_generator.rb b/vendor/plugins/coulda/generators/view/view_generator.rb
index ee394ef..f2f865f 100644
--- a/vendor/plugins/coulda/generators/view/view_generator.rb
+++ b/vendor/plugins/coulda/generators/view/view_generator.rb
@@ -2,12 +2,14 @@ class ViewGenerator < Rails::Generator::NamedBase
def manifest
record do |m|
m.directory File.join('app/views', class_path, file_name)
+ m.directory 'features'
- # View template for specified action.
if actions.include?("new")
path = File.join('app/views', class_path, file_name, "new.html.erb")
- m.template 'view_new.html.erb', path,
- :assigns => { :action => action, :path => path }
+ m.template 'view_new.html.erb', path
+
+ path = File.join('features', "#{file_name.pluralize}.feature")
+ m.template 'feature.feature', path
end
end
end
--
libgit2 0.21.2