Skip to content

fixing the controller spec generator to not emit deprecation warnings #862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/generators/rspec/scaffold/templates/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@
describe "with invalid params" do
it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
# Trigger the behavior that occurs when invalid params are submitted
<%= class_name %>.any_instance.stub(:save).and_return(false)
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
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)
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
expect(response).to render_template("new")
end
Expand Down Expand Up @@ -134,15 +134,15 @@
it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" 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)
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
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)
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
expect(response).to render_template("edit")
end
Expand Down