Module: RSpec::Rails::Mocks::ActiveRecordInstanceMethods
- Defined in:
- lib/rspec/rails/mocks.rb
Instance Method Summary collapse
-
#[](key) ⇒ Object
Transforms the key to a method and calls it.
-
#destroy ⇒ Object
Stubs ‘persisted?` to return `false` and `id` to return `nil`.
-
#new_record? ⇒ Boolean
Returns the opposite of ‘persisted?`.
Instance Method Details
#[](key) ⇒ Object
Transforms the key to a method and calls it.
40 41 42 |
# File 'lib/rspec/rails/mocks.rb', line 40 def [](key) send(key) end |
#destroy ⇒ Object
Stubs ‘persisted?` to return `false` and `id` to return `nil`.
34 35 36 37 |
# File 'lib/rspec/rails/mocks.rb', line 34 def destroy self.stub(:persisted?) { false } self.stub(:id) { nil } end |
#new_record? ⇒ Boolean
Returns the opposite of ‘persisted?`
45 46 47 |
# File 'lib/rspec/rails/mocks.rb', line 45 def new_record? !persisted? end |