diff --git a/README.md b/README.md index c8fe8bf9..450761f3 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ complex, and error-prone. tests usage of Rails 3's `attr_accessible` and `attr_protected` macros. * **[allow_value](lib/shoulda/matchers/active_model/allow_value_matcher.rb)** tests usage of the `validates_format_of` validation. -* **[ensure_inclusion_of](lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb)** tests - usage of `validates_inclusion_of`. +* **[validate_inclusion_of](lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb)** + tests usage of `validates_inclusion_of`. * **[ensure_exclusion_of](lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb)** tests usage of `validates_exclusion_of`. * **[ensure_length_of](lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb)** tests usage diff --git a/lib/shoulda/matchers/active_model.rb b/lib/shoulda/matchers/active_model.rb index cbe403fa..d43c2576 100644 --- a/lib/shoulda/matchers/active_model.rb +++ b/lib/shoulda/matchers/active_model.rb @@ -5,7 +5,7 @@ require 'shoulda/matchers/active_model/exception_message_finder' require 'shoulda/matchers/active_model/allow_value_matcher' require 'shoulda/matchers/active_model/disallow_value_matcher' require 'shoulda/matchers/active_model/ensure_length_of_matcher' -require 'shoulda/matchers/active_model/ensure_inclusion_of_matcher' +require 'shoulda/matchers/active_model/validate_inclusion_of_matcher' require 'shoulda/matchers/active_model/ensure_exclusion_of_matcher' require 'shoulda/matchers/active_model/validate_absence_of_matcher' require 'shoulda/matchers/active_model/validate_presence_of_matcher' diff --git a/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb similarity index 90% rename from lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb rename to lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb index 177c6496..3f44740f 100644 --- a/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb +++ b/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb @@ -3,7 +3,7 @@ require 'bigdecimal' module Shoulda module Matchers module ActiveModel - # The `ensure_inclusion_of` matcher tests usage of the + # The `validate_inclusion_of` matcher tests usage of the # `validates_inclusion_of` validation, asserting that an attribute can # take a whitelist of values and cannot take values outside of this list. # @@ -19,14 +19,14 @@ module Shoulda # # RSpec # describe Issue do # it do - # should ensure_inclusion_of(:state). + # should validate_inclusion_of(:state). # in_array(%w(open resolved unresolved)) # end # end # # # Test::Unit # class IssueTest < ActiveSupport::TestCase - # should ensure_inclusion_of(:state). + # should validate_inclusion_of(:state). # in_array(%w(open resolved unresolved)) # end # @@ -41,12 +41,12 @@ module Shoulda # # # RSpec # describe Issue do - # it { should ensure_inclusion_of(:state).in_range(1..5) } + # it { should validate_inclusion_of(:state).in_range(1..5) } # end # # # Test::Unit # class IssueTest < ActiveSupport::TestCase - # should ensure_inclusion_of(:state).in_range(1..5) + # should validate_inclusion_of(:state).in_range(1..5) # end # # #### Optional qualifiers @@ -67,7 +67,7 @@ module Shoulda # # RSpec # describe Issue do # it do - # should ensure_inclusion_of(:severity). + # should validate_inclusion_of(:severity). # in_array(%w(low medium high)). # with_message('Severity must be low, medium, or high') # end @@ -75,7 +75,7 @@ module Shoulda # # # Test::Unit # class IssueTest < ActiveSupport::TestCase - # should ensure_inclusion_of(:severity). + # should validate_inclusion_of(:severity). # in_array(%w(low medium high)). # with_message('Severity must be low, medium, or high') # end @@ -103,7 +103,7 @@ module Shoulda # # RSpec # describe Person do # it do - # should ensure_inclusion_of(:age). + # should validate_inclusion_of(:age). # in_range(0..65). # with_low_message('You do not receive any benefits') # end @@ -111,7 +111,7 @@ module Shoulda # # # Test::Unit # class PersonTest < ActiveSupport::TestCase - # should ensure_inclusion_of(:age). + # should validate_inclusion_of(:age). # in_range(0..65). # with_low_message('You do not receive any benefits') # end @@ -139,7 +139,7 @@ module Shoulda # # RSpec # describe Person do # it do - # should ensure_inclusion_of(:age). + # should validate_inclusion_of(:age). # in_range(0..21). # with_high_message("You're too old for this stuff") # end @@ -147,7 +147,7 @@ module Shoulda # # # Test::Unit # class PersonTest < ActiveSupport::TestCase - # should ensure_inclusion_of(:age). + # should validate_inclusion_of(:age). # in_range(0..21). # with_high_message("You're too old for this stuff") # end @@ -169,7 +169,7 @@ module Shoulda # # RSpec # describe Issue do # it do - # should ensure_inclusion_of(:state). + # should validate_inclusion_of(:state). # in_array(%w(open resolved unresolved)). # allow_nil # end @@ -177,7 +177,7 @@ module Shoulda # # # Test::Unit # class IssueTest < ActiveSupport::TestCase - # should ensure_inclusion_of(:state). + # should validate_inclusion_of(:state). # in_array(%w(open resolved unresolved)). # allow_nil # end @@ -199,7 +199,7 @@ module Shoulda # # RSpec # describe Issue do # it do - # should ensure_inclusion_of(:state). + # should validate_inclusion_of(:state). # in_array(%w(open resolved unresolved)). # allow_blank # end @@ -207,24 +207,25 @@ module Shoulda # # # Test::Unit # class IssueTest < ActiveSupport::TestCase - # should ensure_inclusion_of(:state). + # should validate_inclusion_of(:state). # in_array(%w(open resolved unresolved)). # allow_blank # end # - # @return [EnsureInclusionOfMatcher] + # @return [ValidateInclusionOfMatcher] # - def ensure_inclusion_of(attr) - EnsureInclusionOfMatcher.new(attr) + def validate_inclusion_of(attr) + ValidateInclusionOfMatcher.new(attr) end + alias_method :ensure_inclusion_of, :validate_inclusion_of # @private - class EnsureInclusionOfMatcher < ValidationMatcher + class ValidateInclusionOfMatcher < ValidationMatcher ARBITRARY_OUTSIDE_STRING = 'shouldamatchersteststring' ARBITRARY_OUTSIDE_FIXNUM = 123456789 ARBITRARY_OUTSIDE_DECIMAL = BigDecimal.new('0.123456789') BOOLEAN_ALLOWS_BOOLEAN_MESSAGE = <