Class: Mongoid::Matchers::SaveMatcher
- Inherits:
-
Object
- Object
- Mongoid::Matchers::SaveMatcher
- Defined in:
- lib/matchers/document.rb
Instance Method Summary (collapse)
- - (Object) description
- - (Object) failure_message_for_should
- - (Object) failure_message_for_should_not
-
- (SaveMatcher) initialize(attributes = {})
constructor
A new instance of SaveMatcher.
- - (Boolean) matches?(actual)
Constructor Details
- (SaveMatcher) initialize(attributes = {})
A new instance of SaveMatcher
62 63 64 |
# File 'lib/matchers/document.rb', line 62 def initialize(attributes = {}) @attributes = attributes end |
Instance Method Details
- (Object) description
81 82 83 |
# File 'lib/matchers/document.rb', line 81 def description "save properly" end |
- (Object) failure_message_for_should
73 74 75 |
# File 'lib/matchers/document.rb', line 73 def "Expected #{@actual.inspect} to save properly, got #{@actual.errors..to_sentence}" end |
- (Object) failure_message_for_should_not
77 78 79 |
# File 'lib/matchers/document.rb', line 77 def "Expected #{@actual.inspect} to not save, got saved instead" end |
- (Boolean) matches?(actual)
66 67 68 69 70 71 |
# File 'lib/matchers/document.rb', line 66 def matches?(actual) @actual = actual.is_a?(Class) ? ( defined?(::Factory) ? ::Factory.build(actual.name.underscore, @attributes) : actual.new(@attributes)) : actual @actual.valid? and @actual.save end |