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

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

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject



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

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

#connectionObject



144
145
146
# File 'lib/rspec/rails/mocks.rb', line 144

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

#new_record?Boolean

Returns:

  • (Boolean)


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

def new_record?
  !persisted?
end