Sha256: 5a05430e63921aa7ff7c29b28908e6ab3e69ee24121ddfeaf3fb8f6af8c6aef3

Contents?: true

Size: 804 Bytes

Versions: 1

Compression:

Stored size: 804 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 failure_message_when_negated
        "expected to not have many #{@children} through #{@broker}"
      end
      
      def description
        "has many #{@children} through #{@broker}"
      end
    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_through.rb