Conversation
mcmire
left a comment
There was a problem hiding this comment.
Hey @stephannv, I think this is a great idea! I would probably suggest that we extract adding Rails 7.1 to another PR as it may cause CI failures. As for whether we should handle the apply_to_nil option by adding another method or not, I think we should keep it simple and stick to from and to like you've done here.
One thing about this is that we might want to implement a negative version of the matcher. Every matcher can be executed via should_not, and that may match or may not match, just as with should. We might want to have another failure message in that case.
Other than that this looks great!
c10b031 to
4e3f6b9
Compare
|
Done @mcmire . Can you take a look again? I tried to create another PR focused on adding Rails 7.1 to pipeline but I faced some issues, I will give another try later. |
|
Any updates on this PR? |
@Sub-Xaero I was waiting 7.1 release to update this PR, but I think I don't need to wait. |
|
@Sub-Xaero I remember now, this PR is waiting |
4e3f6b9 to
b824485
Compare
1c6bacb to
0188a17
Compare
|
Hi @matsales28 , are you the new code owner for this PR? I rebased it with main, I think it's ready for review now. Your feedback will be very much appreciated. |
Yes, I'll look at this PR next week. I'm pretty busy at the moment with all the holidays. |
matsales28
left a comment
There was a problem hiding this comment.
Overall it looks good to me. Left some small suggestions but once adjusted we're ready to merge. One thing that could make it even better is when we're dealing with several attributes, it would be awesome if we could check all of them and then provide an error message listing all the attributes that didn't pass the normalization. Right now, the way it's set up, only the first one that doesn't meet the criteria shows up in the error message. We can make this on an next PR.
0188a17 to
132c3c6
Compare
Yeah @matsales28 , I think it would be a great improvement. Thanks for the feedback, I think I addressed everything. Let me know if I'm missing something. |
132c3c6 to
3e35b4c
Compare
3e35b4c to
8169b29
Compare
|
Sorry for that @matsales28 , I think it's working now. |
Why
Rails 7.1 adds
normalizesAPI.I think would be nice to shoulda-matchers to have a matchers to easily test the new
normalizesAPI, similar toallow_value/allow_valuesmatchers. I'm using on my project and this:Will become this:
What do you think about? This PR makes sense?
Some considerations:
normalize(attr),from(value)andto(value), I'm open to change.normalizesacceptsapply_to_niloption, but I think this should be tested in its own spec, like