Class: Shoulda::Matchers::ActiveModel::ValidateTimelinessMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveModel::ValidateTimelinessMatcher
- Defined in:
- lib/beyond_the_api_test_helpers/shoulda/validate_timeliness.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
-
#initialize(attribute, date_type) ⇒ ValidateTimelinessMatcher
constructor
A new instance of ValidateTimelinessMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attribute, date_type) ⇒ ValidateTimelinessMatcher
Returns a new instance of ValidateTimelinessMatcher.
10 11 12 13 14 |
# File 'lib/beyond_the_api_test_helpers/shoulda/validate_timeliness.rb', line 10 def initialize(attribute, date_type) @attribute = attribute @date_type = date_type @options = {} end |
Instance Method Details
#description ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/beyond_the_api_test_helpers/shoulda/validate_timeliness.rb', line 40 def description description = "ensure #{@attribute} has a valid #{@date_type} " %w(before on_or_before after on_or_after between).each do |validator| symbolized_validator = validator.to_sym if @options.key?(symbolized_validator) description << "#{validator.tr('_', ' ')} #{@options[symbolized_validator]}" end end description end |
#failure_message ⇒ Object Also known as: failure_message_for_should
30 31 32 |
# File 'lib/beyond_the_api_test_helpers/shoulda/validate_timeliness.rb', line 30 def "Expected #{expectation} (#{@missing})" end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
35 36 37 |
# File 'lib/beyond_the_api_test_helpers/shoulda/validate_timeliness.rb', line 35 def "Did not expect #{expectation}" end |
#matches?(subject) ⇒ Boolean
25 26 27 28 |
# File 'lib/beyond_the_api_test_helpers/shoulda/validate_timeliness.rb', line 25 def matches?(subject) @subject = subject valid_date_according_to_type? && end |