When upgrading a project to the Rails 5.2 pre-release we started to see
some deprecation warnings in our RSpec runs.
The warnings were as follows, and occurred wherever
have_success_status and the like
were used in tests.
.DEPRECATION WARNING: The success? predicate is deprecated and will be removed in Rails 6.0. Please use successful? as provided by Rack::Response::Helpers. (called from matches? at rspec/rails/matchers/have_http_status.rb:263)
This was annoying because many controller tests use
Rails, with this commit decided, in very reasonable fashion, to standardize the response status checking methods in ActionDispatch::TestResponse.
The team simply deprecated the
with the suggestion to use the
server_error? methods pre-existing in
ActionDispatch::TestResponse inherits from
have_http_status matcher called these methods
in a meta-sense, by mapping the
symbols to corresponding methods invoked on the response.
How to repair?
One way to repair this would have been to support the replacement methods,
successful? and require any extant tests using, for example,
have_http_status(:success) to make the change to
This would possibly be defensible as a “follow closely as a thin wrapper on Rails” strategy. Unfortunately, it would break a mountain of tests!
not_found? methods have
been available to
Rack::Response::Helpers for many many years.
The method provided
introduces the new status codes,
:server_error while maintaining support for the Rails deprecated ones.
It does so by mapping, for example,
:success to the
Thus the world of
rspec-rails turns in accordance with the heavens,
that is, Rails.