|
87 | 87 | describe "with invalid params" do
|
88 | 88 | it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
|
89 | 89 | # 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) |
91 | 91 | post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
|
92 | 92 | expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
93 | 93 | end
|
94 | 94 |
|
95 | 95 | it "re-renders the 'new' template" do
|
96 | 96 | # 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) |
98 | 98 | post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
|
99 | 99 | expect(response).to render_template("new")
|
100 | 100 | end
|
|
134 | 134 | it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
|
135 | 135 | <%= file_name %> = <%= class_name %>.create! valid_attributes
|
136 | 136 | # 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) |
138 | 138 | put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
|
139 | 139 | expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
140 | 140 | end
|
141 | 141 |
|
142 | 142 | it "re-renders the 'edit' template" do
|
143 | 143 | <%= file_name %> = <%= class_name %>.create! valid_attributes
|
144 | 144 | # 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) |
146 | 146 | put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
|
147 | 147 | expect(response).to render_template("edit")
|
148 | 148 | end
|
|
0 commit comments