module RSpec::ActiveModel::Mocks::Mocks::ActiveRecordStubExtensions

Public Instance Methods

as_new_record() click to toggle source

Stubs `id` (or other primary key method) to return nil

Calls superclass method
# File lib/rspec/active_model/mocks/mocks.rb, line 199
def as_new_record
  self.__send__("#{self.class.primary_key}=", nil)
  super
end
connection() click to toggle source

Raises an IllegalDataAccessException (stubbed models are not allowed to access the database) @raises IllegalDataAccessException

# 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?() click to toggle source

Returns the opposite of `persisted?`.

# File lib/rspec/active_model/mocks/mocks.rb, line 205
def new_record?
  !persisted?
end