Module: RSpec::Rails::Mocks::ActiveRecordStubExtensions
- Defined in:
- lib/rspec/rails/mocks.rb
Instance Method Summary collapse
-
#as_new_record ⇒ Object
Stubs ‘id` (or other primary key method) to return nil.
-
#connection ⇒ Object
Raises an IllegalDataAccessException (stubbed models are not allowed to access the database).
-
#new_record? ⇒ Boolean
Returns the opposite of ‘persisted?`.
Instance Method Details
#as_new_record ⇒ Object
Stubs ‘id` (or other primary key method) to return nil
166 167 168 169 |
# File 'lib/rspec/rails/mocks.rb', line 166 def as_new_record self.__send__("#{self.class.primary_key}=", nil) super end |
#connection ⇒ Object
Raises an IllegalDataAccessException (stubbed models are not allowed to access the database)
178 179 180 |
# File 'lib/rspec/rails/mocks.rb', line 178 def connection raise RSpec::Rails::IllegalDataAccessException.new("stubbed models are not allowed to access the database") end |
#new_record? ⇒ Boolean
Returns the opposite of ‘persisted?`.
172 173 174 |
# File 'lib/rspec/rails/mocks.rb', line 172 def new_record? !persisted? end |