Created
February 2, 2013 16:34
-
-
Save olly/4698150 to your computer and use it in GitHub Desktop.
Custom rspec Matcher for Strict Validations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matcher = ->(model) do | |
begin | |
model.valid? | |
true | |
rescue ActiveModel::StrictValidationFailed | |
false | |
end | |
end | |
RSpec::Matchers.define :pass_strict_validations do | |
match(&matcher) | |
end | |
RSpec::Matchers.define :fail_strict_validations do | |
match do |model| | |
!matcher.call(model) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment