From 01e64cb2f67c0fc9f0b03b5e1b975caf4438cdf6 Mon Sep 17 00:00:00 2001 From: Mauro George Date: Wed, 1 Jul 2015 18:19:33 -0300 Subject: [PATCH] Keep consistency on allow_blank and allow_nil qualifiers After some discussion[1] was decided that these qualifiers do not accept any parameter. https://github.com/thoughtbot/shoulda-matchers/pull/722 --- NEWS.md | 12 ++++++++++++ .../active_model/validate_inclusion_of_matcher.rb | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index ba3b99674..ec569ff9c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,15 @@ +# HEAD (unreleased) + +### Improvements + +* For consistency with other matchers, the `allow_nil` and `allow_blank` + qualifiers on the `validate_inclusion_of` matcher does not take any arguments; + using these qualifiers will always enable these options. + + * *Pull request: [#747]* + +[#747]: https://github.com/thoughtbot/shoulda-matchers/pull/747 + # 3.1.1 ### Bug fixes diff --git a/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb index fb38410d7..f06325217 100644 --- a/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +++ b/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb @@ -310,8 +310,8 @@ def in_range(range) self end - def allow_blank(allow_blank = true) - @options[:allow_blank] = allow_blank + def allow_blank + @options[:allow_blank] = true self end @@ -319,8 +319,8 @@ def expects_to_allow_blank? @options[:allow_blank] end - def allow_nil(allow_nil = true) - @options[:allow_nil] = allow_nil + def allow_nil + @options[:allow_nil] = true self end