Class: Mongomatic::Expectations::Expected

Inherits:
Expectation
  • Object
show all
Defined in:
lib/mongomatic/expectations/expected.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/expected.rb', line 4

def self.name
  "expected"
end

Instance Method Details

#to_beObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/mongomatic/expectations/expected.rb', line 8

def to_be
  case value
  when Proc
    add_error_msg unless value.call
  when Symbol
    add_error_msg unless instance.send(value)
  else
    add_error_msg unless value
  end
end

#to_not_beObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/mongomatic/expectations/expected.rb', line 19

def to_not_be
  case value
  when Proc
    add_error_msg if value.call
  when Symbol
    add_error_msg if instance.send(value)
  else
    add_error_msg if value
  end
end