Class: RSpec::ValidatesTimeliness::Matchers::ValidationMatcher
- Inherits:
-
Object
- Object
- RSpec::ValidatesTimeliness::Matchers::ValidationMatcher
- Defined in:
- lib/rspec-validates_timeliness/matchers/validation_matcher.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Instance Method Summary collapse
- #after(value = nil, &block) ⇒ Object
- #before(value = nil, &block) ⇒ Object
- #between(value) ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(attr_name) ⇒ ValidationMatcher
constructor
A new instance of ValidationMatcher.
- #is_at(value = nil, &block) ⇒ Object
- #matches?(subject) ⇒ Boolean
- #on_or_after(value = nil, &block) ⇒ Object
- #on_or_before(value = nil, &block) ⇒ Object
Constructor Details
#initialize(attr_name) ⇒ ValidationMatcher
Returns a new instance of ValidationMatcher.
14 15 16 17 18 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 14 def initialize(attr_name) @attr_name = attr_name @options = {} @description = MessageBuilder.new(base_description) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 12 def description @description end |
Instance Method Details
#after(value = nil, &block) ⇒ Object
25 26 27 28 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 25 def after(value = nil, &block) [__method__] = block_given? ? block : value self end |
#before(value = nil, &block) ⇒ Object
35 36 37 38 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 35 def before(value = nil, &block) [__method__] = block_given? ? block : value self end |
#between(value) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 45 def between(value) case value when Array, Range [:on_or_after] = value.first [value.is_a?(Range) && value.exclude_end? ? :before : :on_or_before] = value.last end self end |
#failure_message ⇒ Object
61 62 63 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 61 def "Expected #{description}" end |
#failure_message_when_negated ⇒ Object
65 66 67 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 65 def "Did not expect #{description}" end |
#is_at(value = nil, &block) ⇒ Object
20 21 22 23 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 20 def is_at(value = nil, &block) [__method__] = block_given? ? block : value self end |
#matches?(subject) ⇒ Boolean
55 56 57 58 59 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 55 def matches?(subject) @subject = subject attribute_exist? && end |
#on_or_after(value = nil, &block) ⇒ Object
30 31 32 33 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 30 def on_or_after(value = nil, &block) [__method__] = block_given? ? block : value self end |
#on_or_before(value = nil, &block) ⇒ Object
40 41 42 43 |
# File 'lib/rspec-validates_timeliness/matchers/validation_matcher.rb', line 40 def on_or_before(value = nil, &block) [__method__] = block_given? ? block : value self end |