diff --git a/NEWS.md b/NEWS.md index aa22291b2..6065ab3fa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -77,6 +77,13 @@ * Add `join_table` qualifier to `have_and_belong_to_many`. ([#556]) +* `allow_values` is now an alias for `allow_value`. This makes more sense when + checking against multiple values: + + it { should allow_values('this', 'and', 'that') } + + ([#692]) + [#402]: https://github.com/thoughtbot/shoulda-matchers/pull/402 [#587]: https://github.com/thoughtbot/shoulda-matchers/pull/587 [#662]: https://github.com/thoughtbot/shoulda-matchers/pull/662 @@ -94,6 +101,7 @@ [#556]: https://github.com/thoughtbot/shoulda-matchers/pull/556 [#457]: https://github.com/thoughtbot/shoulda-matchers/pull/457 [#694]: https://github.com/thoughtbot/shoulda-matchers/pull/694 +[#692]: https://github.com/thoughtbot/shoulda-matchers/pull/692 # 2.8.0 diff --git a/lib/shoulda/matchers/active_model/allow_value_matcher.rb b/lib/shoulda/matchers/active_model/allow_value_matcher.rb index 599ac94bf..ea356cd10 100644 --- a/lib/shoulda/matchers/active_model/allow_value_matcher.rb +++ b/lib/shoulda/matchers/active_model/allow_value_matcher.rb @@ -194,6 +194,7 @@ def allow_value(*values) AllowValueMatcher.new(*values) end end + alias_method :allow_values, :allow_value # @private class AllowValueMatcher diff --git a/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb index e118ac2a6..ba341552e 100644 --- a/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb @@ -1,5 +1,13 @@ require 'unit_spec_helper' +describe Shoulda::Matchers::ActiveModel do + describe '#allow_values' do + it 'is aliased to #allow_value' do + expect(method(:allow_values)).to eq(method(:allow_value)) + end + end +end + describe Shoulda::Matchers::ActiveModel::AllowValueMatcher, type: :model do context "#description" do it 'describes itself with multiple values' do