Sha256: 95e6ca8762d53d830e9245200e1bf669a9fb9c61e2eb85659bdc625f1c5da824

Contents?: true

Size: 682 Bytes

Versions: 2

Compression:

Stored size: 682 Bytes

Contents

module Mongoid
  module Matchers
    def be_stored_in collection_name
      BeStoredInMatcher.new collection_name
    end

    private

    class BeStoredInMatcher < Matcher
      attr_reader :collection_name

      def initialize collection_name
        @collection_name = collection_name.to_s
      end

      def matches? subject
        class_of(subject).collection_name.to_s == collection_name
      end

      def failure_message
        "Expected #{inspect} to #{description}"
      end

      def negative_failure_message
        "Expected not to #{description}"
      end

      def description
        "be stored in #{collection_name.inspect}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid-minitest-1.2.0 lib/matchers/document/be_stored_in.rb
mongoid-minitest-1.1.0 lib/matchers/document/be_stored_in.rb