Class: NormalizeDigits::Matchers::NormalizeDigitsForMatcher
- Inherits:
-
Object
- Object
- NormalizeDigits::Matchers::NormalizeDigitsForMatcher
- Defined in:
- lib/normalize_digits/matchers.rb
Overview
Matcher class
Instance Method Summary collapse
- #description ⇒ Object
-
#failure_message ⇒ Object
(also: #failure_message_for_should)
RSpec 3.x.
-
#failure_message_when_negated ⇒ Object
(also: #failure_message_for_should_not, #negative_failure_message)
RSpec 3.x.
-
#initialize(attribute) ⇒ NormalizeDigitsForMatcher
constructor
A new instance of NormalizeDigitsForMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attribute) ⇒ NormalizeDigitsForMatcher
Returns a new instance of NormalizeDigitsForMatcher.
16 17 18 19 |
# File 'lib/normalize_digits/matchers.rb', line 16 def initialize(attribute) @attribute = attribute @options = {} end |
Instance Method Details
#description ⇒ Object
48 49 50 |
# File 'lib/normalize_digits/matchers.rb', line 48 def description "Englishize non-english digits from #{@attribute}" end |
#failure_message ⇒ Object Also known as: failure_message_for_should
RSpec 3.x
30 31 32 |
# File 'lib/normalize_digits/matchers.rb', line 30 def "Expected to be normalized from #{@attribute}, but it was not" end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not, negative_failure_message
RSpec 3.x
38 39 40 |
# File 'lib/normalize_digits/matchers.rb', line 38 def "Expected to remain on #{@attribute}, but it was normalized" end |
#matches?(subject) ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'lib/normalize_digits/matchers.rb', line 21 def matches?(subject) return false unless subject.send(@attribute).is_a?(String) subject.send("#{@attribute}=", "०۰٠") subject.valid? subject.send(@attribute) == "000" end |