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
190 191 192 193 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 190 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)
202 203 204 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 202 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?
.
196 197 198 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 196 def new_record? !persisted? end |