Skip to content

Instantly share code, notes, and snippets.

@BenEddy
Created August 27, 2013 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenEddy/6348314 to your computer and use it in GitHub Desktop.
Save BenEddy/6348314 to your computer and use it in GitHub Desktop.
class MockActiveRelation < Hash
def scoped?
any?
end
def name_matching(name)
new(name_scope: name)
end
def scoped_by_name?(name)
self[:name_scope] == name
end
def email_matching(email)
new(email_scope: email)
end
def scoped_by_email?(email)
self[:email_scope] == email
end
def new(invocation)
MockActiveRelation[merge(invocation)]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment