class NoBrainer::Matchers::Validations::ValidateFormatOfMatcher
Public Class Methods
new(field)
click to toggle source
Calls superclass method
NoBrainer::Matchers::Validations::HaveValidationMatcher::new
# File lib/matchers/validations/format_of.rb, line 7 def initialize(field) super(field, :format) end
Public Instance Methods
description()
click to toggle source
# File lib/matchers/validations/format_of.rb, line 59 def description options_desc = [] options_desc << " with format #{@format.inspect}" if @format options_desc << " allowing the value #{@valid_value.inspect}" if @valid_value options_desc << " not allowing the value #{@invalid_value.inspect}" if @invalid_value "#{super}#{options_desc.to_sentence}" end
matches?(actual)
click to toggle source
Calls superclass method
NoBrainer::Matchers::Validations::HaveValidationMatcher#matches?
# File lib/matchers/validations/format_of.rb, line 26 def matches?(actual) return false unless result = super(actual) if @format if @validator.options[:with] == @format @positive_result_message = @positive_result_message += " with format #{@validator.options[:format].inspect}" else @negative_result_message = @negative_result_message += " with format #{@validator.options[:format].inspect}" result = false end end if @valid_value if @validator.options[:with] =~ @valid_value @positive_result_message = @positive_result_message += " with #{@valid_value.inspect} as a valid value" else @negative_result_message = @negative_result_message += " with #{@valid_value.inspect} as an invalid value" result = false end end if @invalid_value if @invalid_value !~ @validator.options[:with] @positive_result_message = @positive_result_message += " with #{@invalid_value.inspect} as an invalid value" else @negative_result_message = @negative_result_message += " with #{@invalid_value.inspect} as a valid value" result = false end end result end
not_to_allow(invalid_value)
click to toggle source
# File lib/matchers/validations/format_of.rb, line 21 def not_to_allow(invalid_value) @invalid_value = invalid_value self end
to_allow(valid_value)
click to toggle source
# File lib/matchers/validations/format_of.rb, line 16 def to_allow(valid_value) @valid_value = valid_value self end
with_format(format)
click to toggle source
# File lib/matchers/validations/format_of.rb, line 11 def with_format(format) @format = format self end