class SequelSpec::Matchers::Validation::ValidateLengthMatcher

Attributes

validation_type[R]

Public Instance Methods

additionnal_param_check() click to toggle source
# File lib/sequel_spec/validation/validate_length_matcher.rb, line 24
def additionnal_param_check
  unless validation_type && @additionnal
    raise ArgumentError, "You should specify the type of validation using #is, #is_at_least, #is_at_most or #is_between"
  end
end
additionnal_param_required?() click to toggle source
# File lib/sequel_spec/validation/validate_length_matcher.rb, line 20
def additionnal_param_required?
  true
end
description() click to toggle source
# File lib/sequel_spec/validation/validate_length_matcher.rb, line 7
def description
  desc = "validate that length of #{@attribute.inspect} "
  desc << case validation_type
  when :validates_exact_length then "is exactly"
  when :validates_min_length   then "is greater than or equal to"
  when :validates_max_length   then "is less than or equal to"
  when :validates_length_range then "is included in"
  end << " #{@additionnal.inspect}"

  desc << " with option(s) #{hash_to_nice_string @options}" unless @options.empty?
  desc
end
is(value) click to toggle source
# File lib/sequel_spec/validation/validate_length_matcher.rb, line 30
def is(value)
  unless value.is_a?(Integer)
    raise ArgumentError, "#is expects an Integer, #{value.class} given"
  end

  @additionnal = value
  @validation_type = :validates_exact_length
  self
end
Also aliased as: is_equal_to
is_at_least(value) click to toggle source
# File lib/sequel_spec/validation/validate_length_matcher.rb, line 42
def is_at_least(value)
  unless value.is_a?(Integer)
    raise ArgumentError, "#is_at_least expects an Integer, #{value.class} given"
  end

  @additionnal = value
  @validation_type = :validates_min_length
  self
end
is_at_most(value) click to toggle source
# File lib/sequel_spec/validation/validate_length_matcher.rb, line 52
def is_at_most(value)
  unless value.is_a?(Integer)
    raise ArgumentError, "#is_at_most expects an Integer, #{value.class} given"
  end

  @additionnal = value
  @validation_type = :validates_max_length
  self
end
is_between(value) click to toggle source
# File lib/sequel_spec/validation/validate_length_matcher.rb, line 62
def is_between(value)
  unless value.is_a?(Range)
    raise ArgumentError, "#is_between expects a Range, #{value.class} given"
  end

  @additionnal = value
  @validation_type = :validates_length_range
  self
end
is_equal_to(value)
Alias for: is