Stubs `id` (or other primary key method) to return nil
# File lib/rspec/rails/mocks.rb, line 166 def as_new_record self.__send__("#{self.class.primary_key}=", nil) super end
Raises an IllegalDataAccessException (stubbed models are not allowed to access the database) @raises IllegalDataAccessException
# File lib/rspec/rails/mocks.rb, line 178 def connection raise RSpec::Rails::IllegalDataAccessException.new("stubbed models are not allowed to access the database") end
Returns the opposite of `persisted?`.
# File lib/rspec/rails/mocks.rb, line 172 def new_record? !persisted? end