module RSpec::ActiveModel::Mocks::Mocks::ActiveRecordInstanceMethods
Public Instance Methods
[](key)
click to toggle source
Transforms the key to a method and calls it.
# File lib/rspec/active_model/mocks/mocks.rb, line 56 def [](key) send(key) end
Also aliased as: _read_attribute
_read_attribute(key)
Rails>4.2 uses _read_attribute
internally, as an optimized alternative to record
Alias for: []
association(association_name)
click to toggle source
Returns an object representing an association from the mocked model's perspective. For use by Rails internally only.
# File lib/rspec/active_model/mocks/mocks.rb, line 71 def association(association_name) @associations ||= Hash.new { |h, k| h[k] = Association.new(k) } @associations[association_name] end
destroy()
click to toggle source
Stubs `persisted?` to return `false` and `id` to return `nil`.
# File lib/rspec/active_model/mocks/mocks.rb, line 50 def destroy RSpec::Mocks.allow_message(self, :persisted?).and_return(false) RSpec::Mocks.allow_message(self, :id).and_return(nil) end
new_record?()
click to toggle source
Returns the opposite of `persisted?`
# File lib/rspec/active_model/mocks/mocks.rb, line 65 def new_record? !persisted? end