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

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

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject



118
119
120
121
# File 'lib/rspec/rails/mocks.rb', line 118

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

#connectionObject



127
128
129
# File 'lib/rspec/rails/mocks.rb', line 127

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

#new_record?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/rspec/rails/mocks.rb', line 123

def new_record?
  !persisted?
end