Class: Shoulda::Matchers::ActiveRecord::NormalizeMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveRecord::NormalizeMatcher
- Defined in:
- lib/shoulda/matchers/active_record/normalize_matcher.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#failure_message ⇒ Object
readonly
Returns the value of attribute failure_message.
-
#failure_message_when_negated ⇒ Object
readonly
Returns the value of attribute failure_message_when_negated.
-
#from_value ⇒ Object
readonly
Returns the value of attribute from_value.
-
#to_value ⇒ Object
readonly
Returns the value of attribute to_value.
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(subject) ⇒ Boolean
- #from(value) ⇒ Object
-
#initialize(*attributes) ⇒ NormalizeMatcher
constructor
A new instance of NormalizeMatcher.
- #matches?(subject) ⇒ Boolean
- #to(value) ⇒ Object
Constructor Details
#initialize(*attributes) ⇒ NormalizeMatcher
Returns a new instance of NormalizeMatcher.
81 82 83 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 81 def initialize(*attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
78 79 80 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 78 def attributes @attributes end |
#failure_message ⇒ Object (readonly)
Returns the value of attribute failure_message.
78 79 80 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 78 def @failure_message end |
#failure_message_when_negated ⇒ Object (readonly)
Returns the value of attribute failure_message_when_negated.
78 79 80 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 78 def @failure_message_when_negated end |
#from_value ⇒ Object (readonly)
Returns the value of attribute from_value.
78 79 80 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 78 def from_value @from_value end |
#to_value ⇒ Object (readonly)
Returns the value of attribute to_value.
78 79 80 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 78 def to_value @to_value end |
Instance Method Details
#description ⇒ Object
85 86 87 88 89 90 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 85 def description %( normalize #{attributes.to_sentence(last_word_connector: ' and ')} from ‹#{from_value.inspect}› to ‹#{to_value.inspect}› ).squish end |
#does_not_match?(subject) ⇒ Boolean
108 109 110 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 108 def does_not_match?(subject) attributes.all? { |attribute| attribute_does_not_match?(subject, attribute) } end |
#from(value) ⇒ Object
92 93 94 95 96 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 92 def from(value) @from_value = value self end |
#matches?(subject) ⇒ Boolean
104 105 106 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 104 def matches?(subject) attributes.all? { |attribute| attribute_matches?(subject, attribute) } end |
#to(value) ⇒ Object
98 99 100 101 102 |
# File 'lib/shoulda/matchers/active_record/normalize_matcher.rb', line 98 def to(value) @to_value = value self end |