module RSpec::Rails::Mocks::ActiveModelStubExtensions

def as_new_record

Stubs `persisted` to return false and `id` to return nil
def as_new_record
  self.stub(:persisted?)  { false }
  self.stub(:id)          { nil }
  self
end

def persisted?

Returns `true` by default. Override with a stub.
def persisted?
  true
end