Sha256: c03da15d5240c0fedae2e8f63af7d478caedb16045cdefa6f105ee033a4962c7

Contents?: true

Size: 681 Bytes

Versions: 5

Compression:

Stored size: 681 Bytes

Contents

module DataMapper
  module Matchers

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

      def matches?(model)
        @model = model
	relation = @model.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 negative_failure_message
        "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

5 entries across 5 versions & 1 rubygems

Version Path
dm-rspec-0.1.2 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec-0.1.1 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec-0.1.0 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec-0.0.2 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec-0.0.1 lib/dm/matchers/have_many_and_belong_to.rb