Skip to content

Instantly share code, notes, and snippets.

@olly
Created February 2, 2013 16:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olly/4698150 to your computer and use it in GitHub Desktop.
Save olly/4698150 to your computer and use it in GitHub Desktop.
Custom rspec Matcher for Strict Validations
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