Class: Mongomatic::Expectations::Match
- Inherits:
-
Expectation
- Object
- Expectation
- Mongomatic::Expectations::Match
- Defined in:
- lib/mongomatic/expectations/match.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
+ (Object) name
4 5 6 |
# File 'lib/mongomatic/expectations/match.rb', line 4 def self.name "match" end |
Instance Method Details
- (Object) to_be
8 9 10 11 12 |
# File 'lib/mongomatic/expectations/match.rb', line 8 def to_be return true if opts[:allow_nil] && value.nil? add_error_msg unless opts[:with].match(value.to_s) end |
- (Object) to_not_be
14 15 16 |
# File 'lib/mongomatic/expectations/match.rb', line 14 def to_not_be add_error_msg if opts[:with].match(value.to_s) end |