Create the allow_values matcher

It is a alias to the actual allow_value matcher.
This commit is contained in:
Mauro George 2015-03-30 18:43:16 -03:00 committed by Elliot Winkler
parent 7c8e3f5081
commit ae77c7d736
3 changed files with 17 additions and 0 deletions

View File

@ -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

View File

@ -194,6 +194,7 @@ module Shoulda
AllowValueMatcher.new(*values)
end
end
alias_method :allow_values, :allow_value
# @private
class AllowValueMatcher

View File

@ -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