Class: Mongoid::Matchers::Document::DocumentMatcher
- Defined in:
- lib/matchers/document/document.rb
Instance Attribute Summary collapse
-
#mod ⇒ Object
readonly
Returns the value of attribute mod.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(mod) ⇒ DocumentMatcher
constructor
A new instance of DocumentMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(mod) ⇒ DocumentMatcher
Returns a new instance of DocumentMatcher.
36 37 38 |
# File 'lib/matchers/document/document.rb', line 36 def initialize mod @mod = mod end |
Instance Attribute Details
#mod ⇒ Object (readonly)
Returns the value of attribute mod.
34 35 36 |
# File 'lib/matchers/document/document.rb', line 34 def mod @mod end |
Instance Method Details
#description ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/matchers/document/document.rb', line 52 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 |
#failure_message ⇒ Object
44 45 46 |
# File 'lib/matchers/document/document.rb', line 44 def "Expected #{inspect} to #{description}" end |
#matches?(subject) ⇒ Boolean
40 41 42 |
# File 'lib/matchers/document/document.rb', line 40 def matches? subject class_of(subject).included_modules.include? mod end |
#negative_failure_message ⇒ Object
48 49 50 |
# File 'lib/matchers/document/document.rb', line 48 def "Expected not to #{description}" end |