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

Defined in:
lib/vendor/plugins/rspec-rails/lib/spec/rails/mocks.rb

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject



51
52
53
54
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/mocks.rb', line 51

def as_new_record
  self.id = nil
  self
end

#connectionObject



45
46
47
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/mocks.rb', line 45

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

#new_record?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/mocks.rb', line 48

def new_record?
  id.nil?
end