module Mongrel2::SpecHelpers
A collection of helper functions that are generally useful for testing Mongrel2::Handlers.
Public Class Methods
included( context )
click to toggle source
Inclusion callback – install some hooks
Calls superclass method
# File lib/mongrel2/testing.rb, line 20 def self::included( context ) context.before( :all ) do setup_config_db end context.around( :each ) do |example| if (( setting = example.metadata[:db] )) if setting == :no_transaction || setting == :without_transaction Loggability[ Mongrel2 ].debug " running without a transaction" example.run else Loggability[ Mongrel2 ].debug " running with a transaction" Mongrel2::Config.db.transaction( rollback: :always ) do example.run end end else example.run end end super end
Public Instance Methods
clean_config_db()
click to toggle source
Truncate all the tables in the current config DB.
# File lib/mongrel2/testing.rb, line 54 def clean_config_db Mongrel2::Config.db.tables.collect {|t| Mongrel2::Config.db[t] }.each( &:truncate ) end
setup_config_db()
click to toggle source
Set up a Mongrel2
configuration database in memory.
# File lib/mongrel2/testing.rb, line 47 def setup_config_db Mongrel2::Config.db ||= Mongrel2::Config.in_memory_db Mongrel2::Config.init_database! end