Class: Mongoid::Matchers::SaveMatcher
- Inherits:
-
Object
- Object
- Mongoid::Matchers::SaveMatcher
- Defined in:
- lib/matchers/document.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(attributes = {}) ⇒ SaveMatcher
constructor
A new instance of SaveMatcher.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ SaveMatcher
Returns a new instance of SaveMatcher.
62 63 64 |
# File 'lib/matchers/document.rb', line 62 def initialize(attributes = {}) @attributes = attributes end |
Instance Method Details
#description ⇒ Object
81 82 83 |
# File 'lib/matchers/document.rb', line 81 def description "save properly" end |
#failure_message_for_should ⇒ Object
73 74 75 |
# File 'lib/matchers/document.rb', line 73 def "Expected #{@actual.inspect} to save properly, got #{@actual.errors..to_sentence}" end |
#failure_message_for_should_not ⇒ Object
77 78 79 |
# File 'lib/matchers/document.rb', line 77 def "Expected #{@actual.inspect} to not save, got saved instead" end |
#matches?(actual) ⇒ Boolean
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 |