Module: RSpec::ActiveModel::Mocks::Mocks::ActiveRecordStubExtensions
- Defined in:
- lib/rspec/active_model/mocks/mocks.rb
Instance Method Summary collapse
-
#as_new_record ⇒ Object
Stubs
id
(or other primary key method) to return nil. -
#connection ⇒ Object
Raises an IllegalDataAccessException (stubbed models are not allowed to access the database).
-
#new_record? ⇒ Boolean
Returns the opposite of
persisted?
.
Instance Method Details
#as_new_record ⇒ Object
Stubs id
(or other primary key method) to return nil
199 200 201 202 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 199 def as_new_record self.__send__("#{self.class.primary_key}=", nil) super end |
#connection ⇒ Object
Raises an IllegalDataAccessException (stubbed models are not allowed to access the database)
211 212 213 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 211 def connection raise RSpec::ActiveModel::Mocks::IllegalDataAccessException.new("stubbed models are not allowed to access the database") end |
#new_record? ⇒ Boolean
Returns the opposite of persisted?
.
205 206 207 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 205 def new_record? !persisted? end |