class MiniTest::Matchers::ActiveModel::ValidateFormatMatcher
Public Class Methods
new(attr)
click to toggle source
Calls superclass method
# File lib/matchers/validate_format_matcher.rb, line 20 def initialize attr @valid, @invalid = nil super attr, :format end
Public Instance Methods
description()
click to toggle source
Calls superclass method
# File lib/matchers/validate_format_matcher.rb, line 51 def description desc = [] desc << " allowing the value #{@valid.inspect}" if @valid desc << " not allowing the value #{@invalid.inspect}" if @invalid super << desc.to_sentence end
matches?(subject)
click to toggle source
Calls superclass method
# File lib/matchers/validate_format_matcher.rb, line 40 def matches? subject validate_invalid_options! @valid, @invalid return false unless @result = super(subject) check_valid_value if @valid check_invalid_value if @invalid @result end
to_allow(valid_value)
click to toggle source
# File lib/matchers/validate_format_matcher.rb, line 26 def to_allow valid_value raise 'You must not call both to_allow and to_not_allow' if @invalid @valid = valid_value self end
to_not_allow(invalid_value)
click to toggle source
# File lib/matchers/validate_format_matcher.rb, line 33 def to_not_allow invalid_value raise 'You must not call both to_allow and to_not_allow' if @valid @invalid = invalid_value self end
Private Instance Methods
check_invalid_value()
click to toggle source
# File lib/matchers/validate_format_matcher.rb, line 69 def check_invalid_value if format !~ @invalid @positive_message << " with #{@invalid.inspect} as a invalid value" else @negative_message << " with #{@invalid.inspect} as a valid value" @result = false end end
check_valid_value()
click to toggle source
# File lib/matchers/validate_format_matcher.rb, line 60 def check_valid_value if format =~ @valid @positive_message << " with #{@valid.inspect} as a valid value" else @negative_message << " with #{@valid.inspect} as an invalid value" @result = false end end
format()
click to toggle source
# File lib/matchers/validate_format_matcher.rb, line 78 def format @with ||= @validator.options[:with] end