Sha256: bbe59642e28d92d346d243da532bc2a6543965b5820c9fdf6e9925c49c294486

Contents?: true

Size: 726 Bytes

Versions: 10

Compression:

Stored size: 726 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 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

10 entries across 10 versions & 2 rubygems

Version Path
dm-rspec-0.2.4 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec2-0.3.0 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec-0.2.3 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec-0.2.2 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec2-0.2.4 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec2-0.2.3 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec2-0.2.2 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec2-0.2.1 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec-0.2.1 lib/dm/matchers/have_many_and_belong_to.rb
dm-rspec-0.2.0 lib/dm/matchers/have_many_and_belong_to.rb