class Shoulda::Matchers::ActiveModel::EnsureExclusionOfMatcher

@private

Public Instance Methods

description() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 105
def description
  "ensure exclusion of #{@attribute} in #{inspect_message}"
end
in_array(array) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 88
def in_array(array)
  @array = array
  self
end
in_range(range) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 93
def in_range(range)
  @range = range
  @minimum = range.first
  @maximum = range.max
  self
end
matches?(subject) click to toggle source
Calls superclass method
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 109
def matches?(subject)
  super(subject)

  if @range
    allows_lower_value &&
      disallows_minimum_value &&
      allows_higher_value &&
      disallows_maximum_value
  elsif @array
    disallows_all_values_in_array?
  end
end
with_message(message) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 100
def with_message(message)
  @expected_message = message if message
  self
end

Private Instance Methods

allows_higher_value() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 134
def allows_higher_value
  allows_value_of(@maximum + 1, expected_message)
end
allows_lower_value() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 130
def allows_lower_value
  @minimum == 0 || allows_value_of(@minimum - 1, expected_message)
end
disallows_all_values_in_array?() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 124
def disallows_all_values_in_array?
  @array.all? do |value|
    disallows_value_of(value, expected_message)
  end
end
disallows_maximum_value() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 142
def disallows_maximum_value
  disallows_value_of(@maximum, expected_message)
end
disallows_minimum_value() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 138
def disallows_minimum_value
  disallows_value_of(@minimum, expected_message)
end
expected_message() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 146
def expected_message
  @expected_message || :exclusion
end
inspect_message() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb, line 150
def inspect_message
  if @range
    @range.inspect
  else
    @array.inspect
  end
end