Class: MiniTest::Matchers::ActiveModel::ValidateAcceptanceMatcher

Inherits:
ValidationMatcher
  • Object
show all
Defined in:
lib/matchers/validate_acceptance_matcher.rb

Instance Method Summary collapse

Methods inherited from ValidationMatcher

#failure_message, #negative_failure_message, #on, #with_message

Methods included from Helpers

#class_of, #to_sentence

Constructor Details

#initialize(attr) ⇒ ValidateAcceptanceMatcher

Returns a new instance of ValidateAcceptanceMatcher.



18
19
20
21
22
# File 'lib/matchers/validate_acceptance_matcher.rb', line 18

def initialize attr
  @accepted = nil

  super attr, :acceptance
end

Instance Method Details

#accept_with(value) ⇒ Object



24
25
26
27
# File 'lib/matchers/validate_acceptance_matcher.rb', line 24

def accept_with value
  @accepted = value
  self
end

#descriptionObject



37
38
39
40
41
# File 'lib/matchers/validate_acceptance_matcher.rb', line 37

def description
  desc = ''
  desc = " accept with #{@accepted.inspect}" if @accepted
  super << desc
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/matchers/validate_acceptance_matcher.rb', line 29

def matches? subject
  return false unless @result = super(subject)

  check_accepted_value if @accepted

  @result
end