Skip to content

Commit

Permalink
Remove deprecated matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Feb 9, 2015
1 parent ab91bbf commit 55c8d09
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 81 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

expect(record).not_to allow_value('good value', *bad_values)

* `ensure_inclusion_of`, `ensure_exclusion_of`, and `ensure_length_of` have been
removed in favor of their `validate_*` counterparts.

# 2.8.0

### Deprecations
Expand Down
10 changes: 0 additions & 10 deletions lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ def validate_exclusion_of(attr)
ValidateExclusionOfMatcher.new(attr)
end

# @deprecated Use {#validate_exclusion_of} instead.
# @return [ValidateExclusionOfMatcher]
def ensure_exclusion_of(attr)
Shoulda::Matchers.warn_about_deprecated_method(
:ensure_exclusion_of,
:validate_exclusion_of
)
validate_exclusion_of(attr)
end

# @private
class ValidateExclusionOfMatcher < ValidationMatcher
def initialize(attribute)
Expand Down
10 changes: 0 additions & 10 deletions lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,6 @@ def validate_inclusion_of(attr)
ValidateInclusionOfMatcher.new(attr)
end

# @deprecated Use {#validate_inclusion_of} instead.
# @return [ValidateInclusionOfMatcher]
def ensure_inclusion_of(attr)
Shoulda::Matchers.warn_about_deprecated_method(
:ensure_inclusion_of,
:validate_inclusion_of
)
validate_inclusion_of(attr)
end

# @private
class ValidateInclusionOfMatcher < ValidationMatcher
ARBITRARY_OUTSIDE_STRING = 'shouldamatchersteststring'
Expand Down
10 changes: 0 additions & 10 deletions lib/shoulda/matchers/active_model/validate_length_of_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,6 @@ def validate_length_of(attr)
ValidateLengthOfMatcher.new(attr)
end

# @deprecated Use {#validate_length_of} instead.
# @return [ValidateLengthOfMatcher]
def ensure_length_of(attr)
Shoulda::Matchers.warn_about_deprecated_method(
:ensure_length_of,
:validate_length_of
)
validate_length_of(attr)
end

# @private
class ValidateLengthOfMatcher < ValidationMatcher
include Helpers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
require 'unit_spec_helper'

describe Shoulda::Matchers::ActiveModel, type: :model do
describe '#ensure_exclusion_of' do
it 'is aliased to #validate_exclusion_of' do
allow(matchers).to receive(:validate_exclusion_of)

silence_warnings do
matchers.ensure_exclusion_of(:attr)
expect(matchers).to have_received(:validate_exclusion_of).with(:attr)
end
end
end

def matchers
@_matchers ||= Object.new.extend(described_class)
end
end

describe Shoulda::Matchers::ActiveModel::ValidateExclusionOfMatcher, type: :model do
context 'an attribute which must be excluded from a range' do
it 'accepts ensuring the correct range' do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
require 'unit_spec_helper'

describe Shoulda::Matchers::ActiveModel, type: :model do
describe '#ensure_inclusion_of' do
it 'is aliased to #validate_inclusion_of' do
allow(matchers).to receive(:validate_inclusion_of)

silence_warnings do
matchers.ensure_inclusion_of(:attr)
expect(matchers).to have_received(:validate_inclusion_of)
end
end
end

def matchers
@_matchers ||= Object.new.extend(described_class)
end
end

describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :model do
shared_context 'for a generic attribute' do
def self.testing_values_of_option(option_name, &block)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
require 'unit_spec_helper'

describe Shoulda::Matchers::ActiveModel, type: :model do
describe '#ensure_length_of' do
it 'is aliased to #validate_length_of' do
allow(matchers).to receive(:validate_length_of)

silence_warnings do
matchers.ensure_length_of(:attr)
expect(matchers).to have_received(:validate_length_of).with(:attr)
end
end
end

def matchers
@_matchers ||= Object.new.extend(described_class)
end
end

describe Shoulda::Matchers::ActiveModel::ValidateLengthOfMatcher, type: :model do
context 'an attribute with a non-zero minimum length validation' do
it 'accepts ensuring the correct minimum length' do
Expand Down

0 comments on commit 55c8d09

Please sign in to comment.