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

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

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject



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

def as_new_record
  self.id = nil
  self
end

#connectionObject



46
47
48
# File 'lib/spec/rails/mocks.rb', line 46

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

#new_record?Boolean

Returns:

  • (Boolean)


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

def new_record?
  id.nil?
end