Class: SequelSpec::Matchers::Validation::ValidateIncludesMatcher

Inherits:
ValidateMatcher show all
Defined in:
lib/sequel_spec/validation/validate_includes_matcher.rb

Instance Method Summary collapse

Methods inherited from ValidateMatcher

#allowing_blank, #allowing_missing, #allowing_nil, #args_to_called_attributes, #valid?, #with_message

Methods inherited from Base

#failure_message, #hash_to_nice_string, #initialize, #matches?, #negative_failure_message, #with_options

Constructor Details

This class inherits a constructor from SequelSpec::Matchers::Base

Instance Method Details

#additionnal_param_checkObject



16
17
18
19
20
# File 'lib/sequel_spec/validation/validate_includes_matcher.rb', line 16

def additionnal_param_check
  unless @additionnal
    raise ArgumentError, "You should specify inclusion using #in"
  end
end

#additionnal_param_required?Boolean

temp workaround

Returns:

  • (Boolean)


12
13
14
# File 'lib/sequel_spec/validation/validate_includes_matcher.rb', line 12

def additionnal_param_required?
  true
end

#descriptionObject



5
6
7
8
9
# File 'lib/sequel_spec/validation/validate_includes_matcher.rb', line 5

def description
  desc = "validate that #{@attribute.inspect} is included in #{@additionnal.inspect}"
  desc << " with option(s) #{hash_to_nice_string @options}" unless @options.empty?
  desc
end

#in(value) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/sequel_spec/validation/validate_includes_matcher.rb', line 22

def in(value)
  unless value.is_a?(Enumerable)
    raise ArgumentError, "#in expects a #{Enumerable}"
  end

  @additionnal = value
  self
end

#validation_typeObject



31
32
33
# File 'lib/sequel_spec/validation/validate_includes_matcher.rb', line 31

def validation_type
  :validates_includes
end