Module: RSpec::Rails::Mocks::ActiveModelInstanceMethods
- Defined in:
- lib/rspec/rails/mocks.rb
Instance Method Summary collapse
-
#as_new_record ⇒ Object
Stubs ‘persisted?` to return false and `id` to return nil.
-
#persisted? ⇒ Boolean
Returns true by default.
-
#respond_to?(message, include_private = false) ⇒ Boolean
Returns false for names matching
/_before_type_cast$/
, otherwise delegates to super.
Instance Method Details
#as_new_record ⇒ Object
Stubs ‘persisted?` to return false and `id` to return nil
14 15 16 17 18 |
# File 'lib/rspec/rails/mocks.rb', line 14 def as_new_record self.stub(:persisted?) { false } self.stub(:id) { nil } self end |
#persisted? ⇒ Boolean
Returns true by default. Override with a stub.
21 22 23 |
# File 'lib/rspec/rails/mocks.rb', line 21 def persisted? true end |
#respond_to?(message, include_private = false) ⇒ Boolean
Returns false for names matching /_before_type_cast$/
, otherwise delegates to super.
27 28 29 |
# File 'lib/rspec/rails/mocks.rb', line 27 def respond_to?(, include_private=false) .to_s =~ /_before_type_cast$/ ? false : super end |