Class: Mongomatic::Expectations::BeReference

Inherits:
Expectation
  • Object
show all
Defined in:
lib/mongomatic/expectations/be_reference.rb

Instance Attribute Summary

Attributes inherited from Expectation

#instance, #message, #opts, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expectation

#add_error_msg, define_to_be?, define_to_not_be?, inherited, #initialize

Constructor Details

This class inherits a constructor from Mongomatic::Expectations::Expectation

Class Method Details

.nameObject



4
5
6
# File 'lib/mongomatic/expectations/be_reference.rb', line 4

def self.name
  "reference"
end

Instance Method Details

#to_beObject



8
9
10
11
12
# File 'lib/mongomatic/expectations/be_reference.rb', line 8

def to_be
  return true if opts[:allow_nil] && value.nil?
    
  add_error_msg unless value.is_a? BSON::ObjectId
end