Sha256: ab16b9844a323a8fd64711ec43eaff76ee5fbbe2217941e85687d209d7a325ff

Contents?: true

Size: 936 Bytes

Versions: 13

Compression:

Stored size: 936 Bytes

Contents

module Shoulda
  module Matchers
    module ActiveRecord
      module AssociationMatchers
        # @private
        class OrderMatcher
          attr_accessor :missing_option

          def initialize(order, name)
            @order = order
            @name = name
            @missing_option = ''
          end

          def description
            "order => #{order}"
          end

          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

          protected

          attr_accessor :subject, :order, :name

          def option_verifier
            @_option_verifier ||= OptionVerifier.new(subject)
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb