Skip to content

Instantly share code, notes, and snippets.

@wycats
Created October 13, 2008 08:15
Show Gist options
  • Save wycats/16509 to your computer and use it in GitHub Desktop.
Save wycats/16509 to your computer and use it in GitHub Desktop.
require "rubygems"
# Add the local gems dir if found within the app root; any dependencies loaded
# hereafter will try to load from the local gems before loading system gems.
if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
$BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
end
require "merb-core"
require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
# this loads all plugins required in your init file so don't add them
# here again, Merb will do it for you
Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test')
DataMapper.auto_migrate!
Spec::Runner.configure do |config|
config.include(Merb::Test::ViewHelper)
config.include(Merb::Test::RouteHelper)
config.include(Merb::Test::ControllerHelper)
config.after(:each) do
repository(:default) do
while repository.adapter.current_transaction
repository.adapter.current_transaction.rollback
repository.adapter.pop_transaction
end
end
end
config.before(:each) do
repository(:default) do
transaction = DataMapper::Transaction.new(repository)
transaction.begin
repository.adapter.push_transaction(transaction)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment