Class: SimpleParams::ValidationMatchers::FormatMatcher
- Inherits:
-
ValidationMatcher
- Object
- Shoulda::Matchers::ActiveModel::ValidationMatcher
- ValidationMatcher
- SimpleParams::ValidationMatchers::FormatMatcher
- Defined in:
- lib/simple_params/validation_matchers/format_matcher.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#default_value ⇒ Object
Returns the value of attribute default_value.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(attribute) ⇒ FormatMatcher
constructor
A new instance of FormatMatcher.
- #into(value) ⇒ Object
- #matches?(subject) ⇒ Boolean
- #with_value(value) ⇒ Object
Constructor Details
#initialize(attribute) ⇒ FormatMatcher
Returns a new instance of FormatMatcher.
10 11 12 13 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 10 def initialize(attribute) super(attribute) @unformatted_value = nil end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
8 9 10 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 8 def attribute @attribute end |
#default_value ⇒ Object
Returns the value of attribute default_value.
8 9 10 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 8 def default_value @default_value end |
Instance Method Details
#description ⇒ Object
31 32 33 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 31 def description "Expect #{@attribute} with_value #{@unformatted_value} to format into #{@expected_value}" end |
#failure_message_for_should ⇒ Object
35 36 37 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 35 def "Expect #{@attribute} with_value #{@unformatted_value} to format into #{@expected_value}" end |
#failure_message_for_should_not ⇒ Object
39 40 41 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 39 def "Expected #{@attribute} with_value #{@unformatted_value} to not format into #{@expected_value}" end |
#into(value) ⇒ Object
20 21 22 23 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 20 def into(value) @expected_value = value self end |
#matches?(subject) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 25 def matches?(subject) super(subject) @subject.send("#{@attribute}=", @unformatted_value) @subject.send(attribute) == @expected_value end |
#with_value(value) ⇒ Object
15 16 17 18 |
# File 'lib/simple_params/validation_matchers/format_matcher.rb', line 15 def with_value(value) @unformatted_value = value self end |