Sha256: 6b94e9d6c63a7d4cf916c7f87f8fa7db4b62bc15fc787fe3aec51e1cc750970e

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 Bytes

Contents

module DataMapper
  module Matchers

    class HaveManyAndBelongTo
      def initialize(name)
        @name = name
      end

      def matches?(model)
        model_class = model.is_a?(Class) ? model : model.class
	relation = model_class.relationships[@name.to_s]
	relation && relation.is_a?(DataMapper::Associations::ManyToMany::Relationship)
      end

      def failure_message
        "expected to have many and belong to #{@name}"
      end

      def failure_message_when_negated
        "expected to not have many and belong to #{@name}"
      end
      
      def description
        "belongs to #{@parent}"
      end
    end


    def have_many_and_belong_to(name)
      HaveManyAndBelongTo.new(name)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-rspec-0.3.0 lib/dm/matchers/have_many_and_belong_to.rb