summaryrefslogtreecommitdiff
path: root/test/test_helper.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-07-14 14:28:35 +0200
committerAzul <azul@leap.se>2013-07-14 16:11:07 +0200
commit374eb7bd3f369cba946d4b8002cd51a499aef32a (patch)
tree5518005eb69b9767eba5ca3027bbcf555de502a8 /test/test_helper.rb
parentcc32ad53286c2c03c88cb55713565c2930796024 (diff)
js integration test for signup, login, logout
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r--test/test_helper.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 0016771..c6794f4 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -10,3 +10,28 @@ Dir["#{File.dirname(__FILE__)}/../*/test/support/**/*.rb"].each { |f| require f
class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
end
+
+require 'capybara/poltergeist'
+Capybara.javascript_driver = :poltergeist
+
+CONFIG_RU = (Rails.root + 'config.ru').to_s
+OUTER_APP = Rack::Builder.parse_file(CONFIG_RU).first
+
+Capybara.register_driver :rack_test do |app|
+ Capybara::RackTest::Driver.new(OUTER_APP)
+end
+
+# Transactional fixtures do not work with Selenium tests, because Capybara
+# uses a separate server thread, which the transactions would be hidden
+# from. We hence use DatabaseCleaner to truncate our test database.
+class BrowserIntegrationTest < ActionDispatch::IntegrationTest
+ # Make the Capybara DSL available
+ include Capybara::DSL
+
+ Capybara.app_host = 'http://localhost:3000'
+ Capybara.server_port = 3000
+ teardown do
+ Capybara.reset_sessions! # Forget the (simulated) browser state
+ Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
+ end
+end