Class: SequelSpec::Matchers::Validation::ValidateTypeMatcher
Instance Method Summary
collapse
#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
Instance Method Details
#additionnal_param_check ⇒ Object
15
16
17
18
19
|
# File 'lib/sequel_spec/validation/validate_type_matcher.rb', line 15
def additionnal_param_check
unless @additionnal
raise ArgumentError, "You should specify the accepted types using #is"
end
end
|
#additionnal_param_required? ⇒ Boolean
11
12
13
|
# File 'lib/sequel_spec/validation/validate_type_matcher.rb', line 11
def additionnal_param_required?
true
end
|
#description ⇒ Object
5
6
7
8
9
|
# File 'lib/sequel_spec/validation/validate_type_matcher.rb', line 5
def description
desc = "validate that type of #{@attribute.inspect} is #{@additionnal.inspect}"
desc << " with option(s) #{hash_to_nice_string @options}" unless @options.empty?
desc
end
|
#is(value) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/sequel_spec/validation/validate_type_matcher.rb', line 21
def is(value)
unless value.is_a?(Class) || value.is_a?(Array)
raise ArgumentError, "#with expects a Class or an array of Classes"
end
@additionnal = value
self
end
|
#validation_type ⇒ Object
30
31
32
|
# File 'lib/sequel_spec/validation/validate_type_matcher.rb', line 30
def validation_type
:validates_type
end
|