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
194 195 196 197 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 194 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)
206 207 208 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 206 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?
.
200 201 202 |
# File 'lib/rspec/active_model/mocks/mocks.rb', line 200 def new_record? !persisted? end |