class Shoulda::Hanami::Matchers::ValidateInclusionOfMatcher
Public Class Methods
new(attribute)
click to toggle source
# File lib/shoulda/hanami/matchers/validate_inclusion_of_matcher.rb, line 9 def initialize(attribute) @attribute = attribute end
Public Instance Methods
description()
click to toggle source
# File lib/shoulda/hanami/matchers/validate_inclusion_of_matcher.rb, line 24 def description "inclusion only '#{@values.inspect}' values on '#{@attribute}'" end
failure_message()
click to toggle source
# File lib/shoulda/hanami/matchers/validate_inclusion_of_matcher.rb, line 28 def failure_message "'#{@attribute}' is include only '#{@values.inspect}'" end
failure_message_when_negated()
click to toggle source
# File lib/shoulda/hanami/matchers/validate_inclusion_of_matcher.rb, line 32 def failure_message_when_negated "'#{@attribute}' is not include only '#{@values.inspect}'" end
in_array(values)
click to toggle source
# File lib/shoulda/hanami/matchers/validate_inclusion_of_matcher.rb, line 36 def in_array(values) @values = values self end
matches?(target)
click to toggle source
# File lib/shoulda/hanami/matchers/validate_inclusion_of_matcher.rb, line 13 def matches?(target) value = nil loop do value = SecureRandom.hex break unless @values.include? value end Matcher.new(target.class.new(@attribute => value), @attribute, :inclusion).matches? end