Sha256: a037ada983ff3caafce42f4fb7db0dca377582f11d6fb45cf127e3328ed5ceae

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

module Mongoid
  module Matchers
    module Document
      DOCUMENT   = Mongoid::Document
      PARANOIA   = Mongoid::Paranoia
      VERSIONING = Mongoid::Versioning
      TIMESTAMPS = Mongoid::Timestamps

      class DocumentMatcher < Matcher
        def initialize mod
          @mod = mod
        end

        def matches? subject
          class_of(subject).included_modules.include? @mod
        end

        def description
          msg = case
                when @mod == DOCUMENT   then ''
                when @mod == PARANOIA   then 'paranoid '
                when @mod == VERSIONING then 'versioned '
                when @mod == TIMESTAMPS then 'timestamped '
                else raise "Unknow Mongoid module #{@mod}"
                end

          "be a #{msg}Mongoid document"
        end
      end

      def be_document
        DocumentMatcher.new DOCUMENT
      end

      def be_paranoid
        DocumentMatcher.new PARANOIA
      end

      def be_versioned
        DocumentMatcher.new VERSIONING
      end

      def be_timestamped
        DocumentMatcher.new TIMESTAMPS
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mongoid-minitest-0.1.5 lib/matchers/document/document.rb
mongoid-minitest-0.1.4 lib/matchers/document/document.rb
mongoid-minitest-0.1.3 lib/matchers/document/document.rb
mongoid-minitest-0.1.3.pre lib/matchers/document/document.rb
mongoid-minitest-0.1.2 lib/matchers/document/document.rb