Skip to content

Instantly share code, notes, and snippets.

@jmdeldin
Created February 21, 2013 18:40
Show Gist options
  • Save jmdeldin/5006998 to your computer and use it in GitHub Desktop.
Save jmdeldin/5006998 to your computer and use it in GitHub Desktop.
A few methods to disable and restore ActiveRecord in a spec helper
def disable_ar
class << ActiveRecord::Base
def fail_connection; fail 'Tried to access the DB'; end
alias_method :old_connection, :connection
alias_method :connection, :fail_connection
end
end
def restore_ar
class << ActiveRecord::Base
alias_method :connection, :old_connection
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment