Comments (4)
We're not enabling users to make expectations based on the default values of the framework. The test you provided, with touch(false)
as a modifier, as an example, passes because of the way we are dealing with boolean missing values as you mentioned, and that might not be the best way to do it, I agree with you on that point. However, I don't think making this change will be worth it, as it will be a breaking change that will add little value to the gem, as we don't often check the default values of configurations.
But I think, especially for newly introduced matchers or qualifiers, that we should make expectations based on the qualifiers used in the spec, even if those qualifiers are defined or not in the framework defaults because they can be overridden at the application level.
Allowing such expectations to pass even without explicit definitions in the association is valuable. It provides flexibility and aligns with the expectation that users can customize and override these settings at the application level.
# app/models/author.rb
class Author < ApplicationRecord
has_many :articles
end
# config/...
config.active_record.strict_loading_by_default = true
RSpec.describe Author do
it { is_expected.to have_many(:articles).strict_loading(true) }
# => this expectation will fail.
end
I'd love to hear your thoughts on this @VSPPedro, as you have more experience maintaining the gem and might have great insights to share.
from shoulda-matchers.
I don't believe it's worth the trouble, but I'm more than happy to review any PRs aiming to make this change.
So, I don't have a strong opinion on this. Sorry.
With that said, excellent review, @matsales28. I couldn't have conducted a more comprehensive one myself.
from shoulda-matchers.
Thank you @matsales28, this makes complete sense. I might have been confused with the fact that strict loading can be configured on several levels on the application, as you mentioned here, and I thought my example was passing because we wanted to support for implicit framework defaults.
But now I understand better, especially what you mentioned about flexibility. I was conscious such a change would be a very breaking one, and that we don't want to introduce a breaking change for any reason.
I will let @VSPPedro share their point of view to gain experience and insights, and then I'm happy to either change this issue or close it, and get back to improving #1607.
from shoulda-matchers.
With that said, we should not make the way we typecast the Boolean values a priority; it's really up to you. Feel free to do so if you are very interested in working on this. Otherwise, I'd recommend continuing the work on #1607 as it's a valuable addition to gem.
from shoulda-matchers.
Related Issues (20)
- Problem when running the tests HOT 7
- Could Not Prove `not_to validate_length_of` Despite Conditional Validation Equally false HOT 3
- Can't be used without Rails and with ActiveModel but not ActiveRecord? HOT 1
- Extend ActiveModel matchers to support arrays attributes HOT 2
- Order of multiple `conditions` qualifier in `have_many` - v5.3.0 HOT 4
- The library doesn't work with frozen-string-literals enabled globally. HOT 1
- Shoulda Matchers ActiveRecord Validate Uniqueness HOT 1
- validation_inclusion_of is returning ArgumentError HOT 1
- Minitest: is there a recommended way to use `shoulda-matchers` without using `shoulda-context` ? HOT 2
- Uniqueness matcher does not account for custom error messages HOT 2
- wrong constant name dummy value on rails 7 HOT 5
- rspec spec/unit fails with ruby 3.3.0dev
- Wrong error with matcher HOT 16
- Cannot validate numericality with dynamic values HOT 2
- Ruby-tests-explorer and shoulda integration HOT 1
- Add `query_constraints` qualifier to the association matcher.
- Numericality matcher not working as expected on 6.0.0 HOT 3
- RangeError: cannot get the first element of beginless range
- polymorph uniq check fails with 6.2 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shoulda-matchers.