class MockRelation
Attributes
mocked_scopes[R]
Public Class Methods
new(*mocked_scopes)
click to toggle source
Calls superclass method
# File lib/mock_relation.rb, line 4 def initialize(*mocked_scopes) @mocked_scopes = mocked_scopes super() end
Public Instance Methods
destroy_all()
click to toggle source
# File lib/mock_relation.rb, line 27 def destroy_all @destroyed = true end
destroyed?()
click to toggle source
# File lib/mock_relation.rb, line 31 def destroyed? @destroyed end
includes(*args)
click to toggle source
# File lib/mock_relation.rb, line 17 def includes(*args) self end
scoped?()
click to toggle source
# File lib/mock_relation.rb, line 9 def scoped? any? end
scoped_by?(scope, *args)
click to toggle source
# File lib/mock_relation.rb, line 13 def scoped_by?(scope, *args) fetch(scope, []).include?(args) end
unscoped()
click to toggle source
# File lib/mock_relation.rb, line 23 def unscoped clone.clear end
Private Instance Methods
method_missing(scope, *args)
click to toggle source
Calls superclass method
# File lib/mock_relation.rb, line 47 def method_missing(scope, *args) mocks_scope?(scope) ? record_invocation(scope, *args) : super end
mocks_scope?(scope)
click to toggle source
# File lib/mock_relation.rb, line 37 def mocks_scope?(scope) mocked_scopes.include?(scope) end
record_invocation(scope, *args)
click to toggle source
# File lib/mock_relation.rb, line 41 def record_invocation(scope, *args) clone.tap do |clone| clone[scope] = fetch(scope, []).push(args) end end