Sha256: 26ca7e01c0f3648097e2106175ce38de1ac297c0661365c265c5a2184be6a328

Contents?: true

Size: 720 Bytes

Versions: 3

Compression:

Stored size: 720 Bytes

Contents

module DataMapper
  module Matchers

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

      def matches?(parent)
        relation = parent.relationships[@children.to_s]

        relation.parent_model == parent 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

3 entries across 3 versions & 1 rubygems

Version Path
dm-rspec-0.1.2 lib/dm/matchers/have_many_through.rb
dm-rspec-0.1.1 lib/dm/matchers/have_many_through.rb
dm-rspec-0.1.0 lib/dm/matchers/have_many_through.rb