Module: RSpec::Rails::Mocks::ActiveRecordStubExtensions

Defined in:
lib/rspec/rails/mocks.rb

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject



130
131
132
133
# File 'lib/rspec/rails/mocks.rb', line 130

def as_new_record
  self.__send__("#{self.class.primary_key}=", nil)
  super
end

#connectionObject



139
140
141
# File 'lib/rspec/rails/mocks.rb', line 139

def connection
  raise RSpec::Rails::IllegalDataAccessException.new("stubbed models are not allowed to access the database")
end

#new_record?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/rspec/rails/mocks.rb', line 135

def new_record?
  !persisted?
end