Module: Rspec::Rails23::Mocking::ModelStubber

Defined in:
lib/rspec/rails23/mocking/model_stubber.rb

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject



15
16
17
18
# File 'lib/rspec/rails23/mocking/model_stubber.rb', line 15

def as_new_record
  self.id = nil
  self
end

#connectionObject



7
8
9
# File 'lib/rspec/rails23/mocking/model_stubber.rb', line 7

def connection
  raise ::Rspec::Rails23::IllegalDataAccessException.new("stubbed/mocked models are not allowed to access the database")
end

#new_record?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rspec/rails23/mocking/model_stubber.rb', line 11

def new_record?
  id.nil?
end