Permalink
Browse files

Generate controller specs using the new expect().to syntax.

  • Loading branch information...
christiannelson committed Dec 26, 2012
1 parent 294f4ba commit 80a3ee820014b6f62dceb4103b34cbeadcae5da7
Showing with 21 additions and 21 deletions.
  1. +21 −21 app_prototype/lib/templates/rspec/scaffold/controller_spec.rb
@@ -22,39 +22,39 @@ def valid_session
end
<% unless options[:singleton] -%>
- describe "GET index" do
+ describe "#index" do
it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
get :index, {}, valid_session
- assigns(:<%= table_name %>).should eq([<%= file_name %>])
+ expect(assigns(:<%= table_name %>)).to eq([<%= file_name %>])
end
end
<% end -%>
- describe "GET show" do
+ describe "#show" do
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
get :show, { :id => <%= file_name %>.to_param }, valid_session
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
end
end
- describe "GET new" do
+ describe "#new" do
it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
get :new, {}, valid_session
- assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
+ expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
end
end
- describe "GET edit" do
+ describe "#edit" do
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
get :edit, { :id => <%= file_name %>.to_param }, valid_session
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
end
end
- describe "POST create" do
+ describe "#create" do
describe "with valid params" do
it "creates a new <%= class_name %>" do
expect {
@@ -64,13 +64,13 @@ def valid_session
it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
post :create, {:<%= ns_file_name %> => valid_attributes }, valid_session
- assigns(:<%= ns_file_name %>).should be_a(<%= class_name %>)
- assigns(:<%= ns_file_name %>).should be_persisted
+ expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
+ expect(assigns(:<%= ns_file_name %>)).to be_persisted
end
it "redirects to the created <%= ns_file_name %>" do
post :create, { :<%= ns_file_name %> => valid_attributes }, valid_session
- response.should redirect_to(<%= class_name %>.last)
+ expect(response).to redirect_to(<%= class_name %>.last)
end
end
@@ -79,19 +79,19 @@ def valid_session
# Trigger the behavior that occurs when invalid params are submitted
<%= class_name %>.any_instance.stub(:save).and_return(false)
post :create, { :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %> }, valid_session
- assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
+ expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
<%= class_name %>.any_instance.stub(:save).and_return(false)
post :create, { :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %> }, valid_session
- response.should render_template("new")
+ expect(response).to render_template("new")
end
end
end
- describe "PUT update" do
+ describe "#update" do
describe "with valid params" do
it "updates the requested <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
@@ -106,13 +106,13 @@ def valid_session
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes }, valid_session
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
end
it "redirects to the <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes }, valid_session
- response.should redirect_to(<%= file_name %>)
+ expect(response).to redirect_to(<%= file_name %>)
end
end
@@ -122,20 +122,20 @@ def valid_session
# Trigger the behavior that occurs when invalid params are submitted
<%= class_name %>.any_instance.stub(:save).and_return(false)
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %> }, valid_session
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
end
it "re-renders the 'edit' template" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
<%= class_name %>.any_instance.stub(:save).and_return(false)
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %> }, valid_session
- response.should render_template("edit")
+ expect(response).to render_template("edit")
end
end
end
- describe "DELETE destroy" do
+ describe "#destroy" do
it "destroys the requested <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
expect {
@@ -146,7 +146,7 @@ def valid_session
it "redirects to the <%= table_name %> list" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
delete :destroy, { :id => <%= file_name %>.to_param }, valid_session
- response.should redirect_to(<%= index_helper %>_url)
+ expect(response).to redirect_to(<%= index_helper %>_url)
end
end

0 comments on commit 80a3ee8

Please sign in to comment.