Skip to content

Commit e96dcea

Browse files
committed
Merge pull request #862 from pungoyal/fix_any_instance_deprecation_warning
fixing the controller spec generator to not emit deprecation warnings
2 parents c566453 + fffa802 commit e96dcea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/generators/rspec/scaffold/templates/controller_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@
8787
describe "with invalid params" do
8888
it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
8989
# Trigger the behavior that occurs when invalid params are submitted
90-
<%= class_name %>.any_instance.stub(:save).and_return(false)
90+
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
9191
post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
9292
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
9393
end
9494
9595
it "re-renders the 'new' template" do
9696
# Trigger the behavior that occurs when invalid params are submitted
97-
<%= class_name %>.any_instance.stub(:save).and_return(false)
97+
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
9898
post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
9999
expect(response).to render_template("new")
100100
end
@@ -134,15 +134,15 @@
134134
it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
135135
<%= file_name %> = <%= class_name %>.create! valid_attributes
136136
# Trigger the behavior that occurs when invalid params are submitted
137-
<%= class_name %>.any_instance.stub(:save).and_return(false)
137+
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
138138
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
139139
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
140140
end
141141
142142
it "re-renders the 'edit' template" do
143143
<%= file_name %> = <%= class_name %>.create! valid_attributes
144144
# Trigger the behavior that occurs when invalid params are submitted
145-
<%= class_name %>.any_instance.stub(:save).and_return(false)
145+
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
146146
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
147147
expect(response).to render_template("edit")
148148
end

0 commit comments

Comments
 (0)