summaryrefslogtreecommitdiff
path: root/lib/generators/nifty/scaffold/templates/tests/rspec/actions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generators/nifty/scaffold/templates/tests/rspec/actions')
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb11
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb6
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb4
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb4
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb4
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb4
-rw-r--r--lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb11
7 files changed, 44 insertions, 0 deletions
diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb
new file mode 100644
index 0000000..ef5a906
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb
@@ -0,0 +1,11 @@
+ it "create action should render new template when model is invalid" do
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
+ post :create
+ response.should render_template(:new)
+ end
+
+ it "create action should redirect when model is valid" do
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
+ post :create
+ response.should redirect_to(<%= item_path_for_spec('url') %>)
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb
new file mode 100644
index 0000000..8372953
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb
@@ -0,0 +1,6 @@
+ it "destroy action should destroy model and redirect to index action" do
+ <%= instance_name %> = <%= class_name %>.first
+ delete :destroy, :id => <%= instance_name %>
+ response.should redirect_to(<%= items_url %>)
+ <%= class_name %>.exists?(<%= instance_name %>.id).should be_false
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb
new file mode 100644
index 0000000..e144904
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb
@@ -0,0 +1,4 @@
+ it "edit action should render edit template" do
+ get :edit, :id => <%= class_name %>.first
+ response.should render_template(:edit)
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb
new file mode 100644
index 0000000..a40ea16
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb
@@ -0,0 +1,4 @@
+ it "index action should render index template" do
+ get :index
+ response.should render_template(:index)
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb
new file mode 100644
index 0000000..22e1b40
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb
@@ -0,0 +1,4 @@
+ it "new action should render new template" do
+ get :new
+ response.should render_template(:new)
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb
new file mode 100644
index 0000000..eaa3d93
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb
@@ -0,0 +1,4 @@
+ it "show action should render show template" do
+ get :show, :id => <%= class_name %>.first
+ response.should render_template(:show)
+ end
diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb
new file mode 100644
index 0000000..c919962
--- /dev/null
+++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb
@@ -0,0 +1,11 @@
+ it "update action should render edit template when model is invalid" do
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
+ put :update, :id => <%= class_name %>.first
+ response.should render_template(:edit)
+ end
+
+ it "update action should redirect when model is valid" do
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
+ put :update, :id => <%= class_name %>.first
+ response.should redirect_to(<%= item_path_for_spec('url') %>)
+ end