Class: Shoulda::Matchers::ActiveModel::NumericalityMatchers::Submatchers

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(submatchers) ⇒ Submatchers

Returns a new instance of Submatchers.



7
8
9
# File 'lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb', line 7

def initialize(submatchers)
  @submatchers = submatchers
end

Instance Method Details

#add(submatcher) ⇒ Object



24
25
26
# File 'lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb', line 24

def add(submatcher)
  @submatchers << submatcher
end

#failure_messageObject



16
17
18
# File 'lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb', line 16

def failure_message
  failing_submatcher.failure_message
end

#failure_message_when_negatedObject



20
21
22
# File 'lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb', line 20

def failure_message_when_negated
  non_failing_submatcher.failure_message_when_negated
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb', line 11

def matches?(subject)
  @subject = subject
  failing_submatchers.empty?
end