Module: RSpec::Rails::Mocks::ActiveModelStubExtensions

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

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject

Stubs persisted to return false and id to return nil



178
179
180
181
182
# File 'lib/rspec/rails/mocks.rb', line 178

def as_new_record
  RSpec::Mocks.allow_message(self, :persisted?).and_return(false)
  RSpec::Mocks.allow_message(self, :id).and_return(nil)
  self
end

#persisted?Boolean

Returns true by default. Override with a stub.

Returns:

  • (Boolean)


185
186
187
# File 'lib/rspec/rails/mocks.rb', line 185

def persisted?
  true
end