Class: Mongoid::Matchers::Document::DocumentMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/matchers/document/document.rb

Instance Method Summary collapse

Methods inherited from Matcher

#failure_message, #negative_failure_message

Methods included from Helpers

#class_of, #to_sentence

Constructor Details

#initialize(mod) ⇒ DocumentMatcher

Returns a new instance of DocumentMatcher.



10
11
12
# File 'lib/matchers/document/document.rb', line 10

def initialize mod
  @mod = mod
end

Instance Method Details

#descriptionObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/matchers/document/document.rb', line 18

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

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/matchers/document/document.rb', line 14

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