Created
September 29, 2010 13:31
-
-
Save danielvlopes/602750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
Daniel,
O Akephalos está funcionando bem aí?
Acabei indo pro Selenium porque estava dando uns bugs estranhos no gc_sweep() do Ruby.
Só por curiosidade... Porque fez esse lance da conexão no ActiveRecord?
Foi uma dica do Carlos Antonio e do Valim... isso mantém a conexão entre os specs em test de integração e tornar os tests um pouco mais rápidos.
Vou testar na minha suíte aqui mas você teve um ganho significativo?
Sim
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Só pra constar no Rspec 2, não se usa mais options[:js] e sim example.metadata[:js]
thanks!