Skip to content

Commit

Permalink
Removed fixtures use from rspec test templates, since I have it hardc…
Browse files Browse the repository at this point in the history
…oded to build from a Machinist blueprint now
  • Loading branch information
Brendon Murphy committed Oct 15, 2009
1 parent ffb7961 commit afabbad
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 0 deletions.
@@ -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
@@ -0,0 +1,6 @@
it "destroy action should destroy model and redirect to index action" do
<%= singular_name %> = <%= class_name %>.first
delete :destroy, :id => <%= singular_name %>
response.should redirect_to(<%= items_path('url') %>)
<%= class_name %>.exists?(<%= singular_name %>.id).should be_false
end
@@ -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
@@ -0,0 +1,11 @@
it "create action should render new template when model is invalid" do
@<%= singular_name %>.stub!(:valid?).and_return(false)
post :create
response.should render_template(:new)
end
it "create action should redirect when model is valid" do
@<%= name.downcase %>.stub!(:valid?).and_return(true)
post :create
response.should redirect_to(<%= item_path_for_spec('url') %>)
end
@@ -0,0 +1,5 @@
it "destroy action should destroy model and redirect to index action" do
delete :destroy, :id => @<%= singular_name %>
response.should redirect_to(<%= items_path('url') %>)
<%= class_name %>.exists?(@<%= singular_name %>.id).should be_false
end
@@ -0,0 +1,11 @@
it "update action should render edit template when model is invalid" do
@<%= singular_name %>.stub!(:valid?).and_return(false)
put :update, :id => <%= class_name %>.first
response.should render_template(:edit)
end

it "update action should redirect when model is valid" do
@<%= singular_name %>.stub!(:valid?).and_return(true)
put :update, :id => <%= class_name %>.first
response.should redirect_to(<%= item_path_for_spec('url') %>)
end
@@ -0,0 +1,4 @@
it "edit action should render edit template" do
get :edit, :id => <%= class_name %>.first
response.should render_template(:edit)
end
@@ -0,0 +1,4 @@
it "index action should render index template" do
get :index
response.should render_template(:index)
end
@@ -0,0 +1,4 @@
it "new action should render new template" do
get :new
response.should render_template(:new)
end
@@ -0,0 +1,4 @@
it "show action should render show template" do
get :show, :id => <%= class_name %>.first
response.should render_template(:show)
end
@@ -0,0 +1,8 @@
require File.dirname(__FILE__) + '/../spec_helper'

describe <%= plural_class_name %>Controller do
integrate_views

<%= controller_methods 'tests/rspec/actions_mocha_mocks' %>
<%= controller_methods 'tests/rspec/actions_shared' %>
end
@@ -0,0 +1,16 @@
require File.dirname(__FILE__) + '/../spec_helper'

describe <%= plural_class_name %>Controller do
fixtures :all
integrate_views

before(:each) do
@<%= singular_name %> = <%= class_name %>.make
<%= class_name %>.stub!(:new).and_return(@<%= singular_name %>)
<%= class_name %>.stub!(:find).and_return(@<%= singular_name %>)
<%= class_name %>.stub!(:all).and_return([@<%= singular_name %>])
end

<%= controller_methods 'tests/rspec/actions_rspec_mocks' %>
<%= controller_methods 'tests/rspec/actions_shared' %>
end

0 comments on commit afabbad

Please sign in to comment.