Module: Remarkable::Mongoid::Matchers
- Defined in:
- lib/remarkable/mongoid/fields.rb,
lib/remarkable/mongoid/relations.rb,
lib/remarkable/mongoid/validate_association.rb,
lib/remarkable/mongoid/validate_uniqueness_of.rb
Defined Under Namespace
Classes: HasFieldMatcher, RelationMatcher, ValidateAssociationMatcher, ValidateUniquenessOfMatcher
Instance Method Summary collapse
-
#be_embedded_in(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document is embedded in another document.
-
#be_referenced_in(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document is referenced in another document.
-
#embed_many(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document embeds many documents.
-
#embed_one(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document embeds another document.
-
#have_field(field, options = {}) ⇒ Remarkable::Mongoid::Matchers::HasFieldMatcher
Specify the document should have a field.
-
#reference_many(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document references many documents.
-
#reference_many_and_be_referenced_in(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document references many documents and is referenced in many documents.
-
#reference_one(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document references another document.
-
#validate_association(attr) ⇒ Remarkable::Mongoid::Matchers::ValidateAssociationMatcher
Specify the document validates the association.
-
#validate_uniqueness_of(attr) ⇒ Remarkable::Mongoid::Matchers::ValidateUniquenessOfMatcher
Specify the document validates the uniqueness of the field’s data.
Instance Method Details
#be_embedded_in(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document is embedded in another document
examples:
it { should :dog }
84 85 86 |
# File 'lib/remarkable/mongoid/relations.rb', line 84 def (attr) RelationMatcher.new(attr, ::Mongoid::Relations::Embedded::In) end |
#be_referenced_in(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document is referenced in another document
examples:
it { should be_referenced_in :dog }
48 49 50 |
# File 'lib/remarkable/mongoid/relations.rb', line 48 def be_referenced_in(attr) RelationMatcher.new(attr, ::Mongoid::Relations::Referenced::In) end |
#embed_many(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document embeds many documents
examples:
it { should :dog }
72 73 74 |
# File 'lib/remarkable/mongoid/relations.rb', line 72 def (attr) RelationMatcher.new(attr, ::Mongoid::Relations::Embedded::Many) end |
#embed_one(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document embeds another document
examples:
it { should :dog }
60 61 62 |
# File 'lib/remarkable/mongoid/relations.rb', line 60 def (attr) RelationMatcher.new(attr, ::Mongoid::Relations::Embedded::One) end |
#have_field(field, options = {}) ⇒ Remarkable::Mongoid::Matchers::HasFieldMatcher
Specify the document should have a field
examples:
it { should have_field :name }
it { should have_field :age, :type => Integer, :default => 0 }
15 16 17 |
# File 'lib/remarkable/mongoid/fields.rb', line 15 def have_field(field, = {}) HasFieldMatcher.new(field, ) end |
#reference_many(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document references many documents
examples:
it { should reference_many :dogs }
24 25 26 |
# File 'lib/remarkable/mongoid/relations.rb', line 24 def reference_many(attr) RelationMatcher.new(attr, ::Mongoid::Relations::Referenced::Many) end |
#reference_many_and_be_referenced_in(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document references many documents and is referenced in many documents
examples:
it { should reference_many_and_be_referenced_in :dog }
36 37 38 |
# File 'lib/remarkable/mongoid/relations.rb', line 36 def reference_many_and_be_referenced_in(attr) RelationMatcher.new(attr, ::Mongoid::Relations::Referenced::ManyToMany) end |
#reference_one(attr) ⇒ Remarkable::Mongoid::Matchers::RelationMatcher
Specify the document references another document
examples:
it { should reference_one :dog }
12 13 14 |
# File 'lib/remarkable/mongoid/relations.rb', line 12 def reference_one(attr) RelationMatcher.new(attr, ::Mongoid::Relations::Referenced::One) end |
#validate_association(attr) ⇒ Remarkable::Mongoid::Matchers::ValidateAssociationMatcher
Specify the document validates the association
examples:
it { should validate_association :dog }
12 13 14 |
# File 'lib/remarkable/mongoid/validate_association.rb', line 12 def validate_association(attr) ValidateAssociationMatcher.new(attr) end |
#validate_uniqueness_of(attr) ⇒ Remarkable::Mongoid::Matchers::ValidateUniquenessOfMatcher
Specify the document validates the uniqueness of the field’s data
examples:
it { should validate_uniqueness_of :dog }
12 13 14 |
# File 'lib/remarkable/mongoid/validate_uniqueness_of.rb', line 12 def validate_uniqueness_of(attr) ValidateUniquenessOfMatcher.new(attr) end |