Module: RSpec::Rails::Mocks::ActiveModelInstanceMethods
- Defined in:
- lib/rspec/rails/mocks.rb
Instance Method Summary (collapse)
-
- (Object) as_new_record
Stubs
persisted?
to return false andid
to return nil. -
- (Boolean) persisted?
Returns true by default.
-
- (Boolean) respond_to?(message, include_private = false)
Returns false for names matching /_before_type_cast$/, otherwise delegates to super.
Instance Method Details
- (Object) as_new_record
Stubs persisted?
to return false and id
to return nil
16 17 18 19 20 |
# File 'lib/rspec/rails/mocks.rb', line 16 def as_new_record RSpec::Mocks.(self, :persisted?).and_return(false) RSpec::Mocks.(self, :id).and_return(nil) self end |
- (Boolean) persisted?
Returns true by default. Override with a stub.
23 24 25 |
# File 'lib/rspec/rails/mocks.rb', line 23 def persisted? true end |
- (Boolean) respond_to?(message, include_private = false)
Returns false for names matching /_before_type_cast$/, otherwise delegates to super.
29 30 31 |
# File 'lib/rspec/rails/mocks.rb', line 29 def respond_to?(, include_private=false) .to_s =~ /_before_type_cast$/ ? false : super end |