Class: Shoulda::Matchers::ActiveRecord::AssociationMatchers::OrderMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveRecord::AssociationMatchers::OrderMatcher
- Defined in:
- lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
Instance Attribute Summary collapse
-
#missing_option ⇒ Object
Returns the value of attribute missing_option.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(order, name) ⇒ OrderMatcher
constructor
A new instance of OrderMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(order, name) ⇒ OrderMatcher
Returns a new instance of OrderMatcher.
9 10 11 12 13 |
# File 'lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb', line 9 def initialize(order, name) @order = order @name = name @missing_option = '' end |
Instance Attribute Details
#missing_option ⇒ Object
Returns the value of attribute missing_option.
7 8 9 |
# File 'lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb', line 7 def missing_option @missing_option end |
Instance Method Details
#description ⇒ Object
15 16 17 |
# File 'lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb', line 15 def description "order => #{order}" end |
#matches?(subject) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb', line 19 def matches?(subject) self.subject = ModelReflector.new(subject, name) if option_verifier.correct_for_relation_clause?(:order, order) true else self.missing_option = "#{name} should be ordered by #{order}" false end end |