Module: Spec::Rails::Mocks::ModelStubber

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

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject



56
57
58
59
# File 'lib/spec/rails/mocks.rb', line 56

def as_new_record
  self.id = nil
  self
end

#connectionObject



50
51
52
# File 'lib/spec/rails/mocks.rb', line 50

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

#new_record?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/spec/rails/mocks.rb', line 53

def new_record?
  id.nil?
end