Skip to content

Commit

Permalink
Avoid deprecated TestResponse#success? method
Browse files Browse the repository at this point in the history
Closes rspec#2009

TestResponse#success? was deprecated with [this
commit](rails/rails@af3500b).
Instead, we can use #successful? from Rack::Response::Helpers. This
method has been available for a long time. I tried this change with
Rails 3.2, 4.2, and 5.2 and everything seemed to work fine.
  • Loading branch information
composerinteralia authored and sebjacobs committed Mar 15, 2019
1 parent 0650b3e commit 63590ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<% else -%>
get :index, params: {}, session: valid_session
<% end -%>
expect(response).to be_success
expect(response).to be_successful
end
end
Expand All @@ -64,7 +64,7 @@
<% else -%>
get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
expect(response).to be_success
expect(response).to be_successful
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/generators/rspec/scaffold/templates/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<% else -%>
get :index, params: {}, session: valid_session
<% end -%>
expect(response).to be_success
expect(response).to be_successful
end
end
Expand All @@ -64,7 +64,7 @@
<% else -%>
get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
expect(response).to be_success
expect(response).to be_successful
end
end
Expand All @@ -75,7 +75,7 @@
<% else -%>
get :new, params: {}, session: valid_session
<% end -%>
expect(response).to be_success
expect(response).to be_successful
end
end
Expand All @@ -87,7 +87,7 @@
<% else -%>
get :edit, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
expect(response).to be_success
expect(response).to be_successful
end
end
Expand Down Expand Up @@ -120,7 +120,7 @@
<% else -%>
post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
<% end -%>
expect(response).to be_success
expect(response).to be_successful
end
end
end
Expand Down Expand Up @@ -161,7 +161,7 @@
<% else -%>
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
<% end -%>
expect(response).to be_success
expect(response).to be_successful
end
end
end
Expand Down

0 comments on commit 63590ab

Please sign in to comment.