Skip to content

Instantly share code, notes, and snippets.

@danielvlopes
Created September 29, 2010 13:31
Show Gist options
  • Save danielvlopes/602750 to your computer and use it in GitHub Desktop.
Save danielvlopes/602750 to your computer and use it in GitHub Desktop.
require 'spec_helper'
require 'steak'
require 'capybara/rails'
require 'database_cleaner'
require 'akephalos'
DatabaseCleaner.strategy = :truncation
Capybara.default_selector = :css
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
Spec::Runner.configure do |config|
config.include Capybara
config.use_transactional_fixtures = false
config.before(:each) { DatabaseCleaner.start; }
config.after(:each) { DatabaseCleaner.clean; }
config.before(:each) do
account.update_attribute(:domain, "acceptance")
Capybara.default_host = account.full_domain
if options[:js]
Capybara.app_host = "http://#{account.full_domain}:9887"
Capybara.current_driver = :akephalos
end
end
config.after(:each) do
Capybara.use_default_driver if options[:js]
Capybara.reset_sessions!
end
end
# Put your acceptance spec helpers inside /spec/acceptance/support
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
@sobrinho
Copy link

Vou testar na minha suíte aqui mas você teve um ganho significativo?

@danielvlopes
Copy link
Author

Sim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment