Skip to content
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

Add test matchers for validators #56

Merged
merged 7 commits into from
Jan 27, 2020
Merged

Add test matchers for validators #56

merged 7 commits into from
Jan 27, 2020

Conversation

StefSchenkelaars
Copy link
Contributor

@StefSchenkelaars StefSchenkelaars commented Jan 24, 2020

I worked on a first version of the test matchers as requested in #48. For now I've only implemented:

  • AttachedValidatorMatcher
  • ContentTypeValidatorMatcher
  • DimensionValidatorMatcher
  • SizeValidatorMatcher

and they should also be extended more to test all options of the validators (like message and validation context). But I hope it is a starting point and that we can add a complete set of matchers for all validators.

@igorkasyanchuk
Copy link
Owner

@StefSchenkelaars this is great news, as I see it's created for mini-test, which I think good start. Maybe you or someone else in the future could implement the same for RSpec.

@StefSchenkelaars
Copy link
Contributor Author

@igorkasyanchuk Well, I actually build it to work with RSpec since that what we use. I am not an expert in minitest but I think they should also work with minitest.

@StefSchenkelaars StefSchenkelaars marked this pull request as ready for review January 24, 2020 10:23
@StefSchenkelaars
Copy link
Contributor Author

I've tested the matchers with minitest and the shoulda context gem. Everything worked as expected and I've updated the readme accordingly.

@igorkasyanchuk
Copy link
Owner

This is fantastic!

@igorkasyanchuk
Copy link
Owner

let me know if you think it's ready for a review

@StefSchenkelaars
Copy link
Contributor Author

Worked a bit on making sure that the stubbing works with both Minitest and RSpec. I now think that works. Also made sure that de dimension validator matcher works with exact matches.

As I said before, there is plenty of work to be done to make the matchers great but they help me quite a bit already in the current state.

But it would be great if you can do a code review!

And a bit unrelated is the rubocop. I ran it on the codebase and there where many failures. But I leave that up to another PR to fix (guess it's a good idea to add rubocop to travis)

@igorkasyanchuk igorkasyanchuk merged commit 3a47cb2 into igorkasyanchuk:master Jan 27, 2020
@igorkasyanchuk
Copy link
Owner

merged and released a new version. Thank you

@StefSchenkelaars StefSchenkelaars deleted the matchers branch January 28, 2020 10:41
@connorshea
Copy link
Contributor

This is great, thanks! 👍

FWIW, pundit-matchers auto-includes itself if the matcher file is required, not sure if there are downsides to that but I figured I'd mention it: https://github.com/chrisalley/pundit-matchers/blob/00c89e7fa1f4dde6f2ad0c03a79db629a8f99e3e/lib/pundit/matchers.rb#L347-L351

@StefSchenkelaars
Copy link
Contributor Author

@connorshea It's probably a good idea to write a new issue for this and include your proposal. Since I think it will get lost since you commented on a closed PR. If I get bored sometimes, I might have a look at this, but you might fix it yourself too ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants