Class: Mongoid::Matchers::BeStoredInMatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection_name) ⇒ BeStoredInMatcher

Returns a new instance of BeStoredInMatcher.



12
13
14
# File 'lib/matchers/document/be_stored_in.rb', line 12

def initialize collection_name
  @collection_name = collection_name.to_s
end

Instance Attribute Details

#collection_nameObject (readonly)

Returns the value of attribute collection_name.



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

def collection_name
  @collection_name
end

Instance Method Details

#descriptionObject



28
29
30
# File 'lib/matchers/document/be_stored_in.rb', line 28

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

#failure_messageObject



20
21
22
# File 'lib/matchers/document/be_stored_in.rb', line 20

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

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/matchers/document/be_stored_in.rb', line 16

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

#negative_failure_messageObject



24
25
26
# File 'lib/matchers/document/be_stored_in.rb', line 24

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