-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Deprecation warning for have(n).errors_on(:attr)
lies in RSpec 2.99
#1026
Comments
@yujinakayama it seems that if you use the I can update the deprecation warning accordingly. |
I'm getting a similar error as yujinakayama, rspec-collection_matchers is installed and required in spec_helper.rb Thanks. |
@kWhittington it is part of the |
@kWhittington -- what version of |
I'm using v0.0.4 and those particular tests seem to be passing. |
@kWhittington -- rspec-rails 2.x had some very implicit ("magical", to some) behavior where it would infer the spec type based on the file location. In RSpec 3 (starting with RC1) you need to opt-in if you want this, or set the spec type yourself: describe MyController, :type => :controller do
end
# or
RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end See #970 for more info. |
Thank you so much for point that out to me! Thanks again! |
How do people feel about changing the deprecation warning to:
IMO this is not a useful tool at all. It's prone to all sorts of false positives. I've typically in the pass rolled my own matcher or done something like: expect{ collection_owner.valid? }.to change{ collection_owner.errors[:attr] }.
to include("error message") Post 3.0, I'd like to consider making this a more proper matcher: expect(collection_owner).to have_validation_error("foo bar").on(:attr) |
@cupakromer that deprecation warning reads very clearly. I also like the idea of having a matcher for this case in the future. |
Do we still need to update the deprecation message? |
😬 we do, however, the error currently comes from |
I'd be ok with that in |
That sounds OK to me, too...but only because it's 2.99 so we're not left with that kind of cruft :). |
This has been implemented. |
Here's an example using
have(n).errors_on(:attr)
:then running
rspec
2.99 (the current2-99-maintenance
head) outputs the following deprecation warning:If you change the expectation to the following as suggested by the warning (currently Transpec also converts it in the same way):
and upgrade to RSpec 3.0 (the current
master
) and runrspec
:This is caused by the removal of the monkey-patch (
ActiveModel::Validations#errors_on
) from rspec-rails (#1005).The text was updated successfully, but these errors were encountered: