Sha256: d2349d6d48355386bdb19e6dd8b858d45153fefda805155d05a7c58dc0143907

Contents?: true

Size: 800 Bytes

Versions: 10

Compression:

Stored size: 800 Bytes

Contents

module DataMapper
  module Matchers

    class HaveManyThrough
      def initialize(children, broker)
        @children, @broker = children, broker
      end

      def matches?(parent)
        parent_class = parent.is_a?(Class) ?  parent : parent.class
        relation = parent_class.relationships[@children.to_s]

        relation.parent_model == parent_class and
        relation.name == @children.to_sym and
        relation.options[:through] == @broker.to_sym
      end

      def failure_message
        "expected to have many #{@children} through #{@broker}"
      end

      def negative_failure_message
        "expected to not have many #{@children} through #{@broker}"
      end
      
      def description
        "has many #{@children} through #{@broker}"
      end
    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_through.rb
dm-rspec2-0.3.0 lib/dm/matchers/have_many_through.rb
dm-rspec-0.2.3 lib/dm/matchers/have_many_through.rb
dm-rspec-0.2.2 lib/dm/matchers/have_many_through.rb
dm-rspec2-0.2.4 lib/dm/matchers/have_many_through.rb
dm-rspec2-0.2.3 lib/dm/matchers/have_many_through.rb
dm-rspec2-0.2.2 lib/dm/matchers/have_many_through.rb
dm-rspec2-0.2.1 lib/dm/matchers/have_many_through.rb
dm-rspec-0.2.1 lib/dm/matchers/have_many_through.rb
dm-rspec-0.2.0 lib/dm/matchers/have_many_through.rb