forked from ryanb/nifty-generators
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed fixtures use from rspec test templates, since I have it hardc…
…oded to build from a Machinist blueprint now
- Loading branch information
Brendon Murphy
committed
Oct 15, 2009
1 parent
ffb7961
commit afabbad
Showing
12 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
rails_generators/nifty_scaffold/templates/tests/rspec/actions_mocha_mocks/create.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
6 changes: 6 additions & 0 deletions
6
rails_generators/nifty_scaffold/templates/tests/rspec/actions_mocha_mocks/destroy.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
11 changes: 11 additions & 0 deletions
11
rails_generators/nifty_scaffold/templates/tests/rspec/actions_mocha_mocks/update.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
11 changes: 11 additions & 0 deletions
11
rails_generators/nifty_scaffold/templates/tests/rspec/actions_rspec_mocks/create.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
5 changes: 5 additions & 0 deletions
5
rails_generators/nifty_scaffold/templates/tests/rspec/actions_rspec_mocks/destroy.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
11 changes: 11 additions & 0 deletions
11
rails_generators/nifty_scaffold/templates/tests/rspec/actions_rspec_mocks/update.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
4 changes: 4 additions & 0 deletions
4
rails_generators/nifty_scaffold/templates/tests/rspec/actions_shared/edit.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
it "edit action should render edit template" do | ||
get :edit, :id => <%= class_name %>.first | ||
response.should render_template(:edit) | ||
end |
4 changes: 4 additions & 0 deletions
4
rails_generators/nifty_scaffold/templates/tests/rspec/actions_shared/index.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
it "index action should render index template" do | ||
get :index | ||
response.should render_template(:index) | ||
end |
4 changes: 4 additions & 0 deletions
4
rails_generators/nifty_scaffold/templates/tests/rspec/actions_shared/new.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
it "new action should render new template" do | ||
get :new | ||
response.should render_template(:new) | ||
end |
4 changes: 4 additions & 0 deletions
4
rails_generators/nifty_scaffold/templates/tests/rspec/actions_shared/show.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
it "show action should render show template" do | ||
get :show, :id => <%= class_name %>.first | ||
response.should render_template(:show) | ||
end |
8 changes: 8 additions & 0 deletions
8
rails_generators/nifty_scaffold/templates/tests/rspec/controller_mocha_mocks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
16 changes: 16 additions & 0 deletions
16
rails_generators/nifty_scaffold/templates/tests/rspec/controller_rspec_mocks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |