Module: RSpec::Rails::Mocks::ActiveModelInstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#as_new_recordObject



9
10
11
12
13
# File 'lib/rspec/rails/mocks.rb', line 9

def as_new_record
  self.stub(:persisted?) { false }
  self.stub(:id) { nil }
  self
end

#persisted?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rspec/rails/mocks.rb', line 15

def persisted?
  true
end

#respond_to?(message, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/rspec/rails/mocks.rb', line 19

def respond_to?(message, include_private=false)
  message.to_s =~ /_before_type_cast$/ ? false : super
end