Permalink
Browse files

First cut at selenium support via "javascript" function

  • Loading branch information...
1 parent ef6e7a9 commit 3b63e1fd5e081caba887f9eb2eb1e355e3daf51b @matschaffer committed Feb 18, 2012
View
26 lib/capybara_rails/selenium.rb
@@ -0,0 +1,26 @@
+require 'capybara/rails'
+require 'active_support/concern'
+
+module CapybaraRails
+ module Selenium
+ extend ActiveSupport::Concern
+
+ module ClassMethods
+ def javascript
+ self.use_transactional_fixtures = false
+ #DatabaseCleaner.strategy = :truncation
+
+ setup do
+ #DatabaseCleaner.start
+ Capybara.current_driver = :selenium
+ page.driver.options[:resynchronize] = true
+ end
+
+ teardown do
+ #DatabaseCleaner.clean
+ Capybara.use_default_driver
+ end
+ end
+ end
+ end
+end
View
2 test/dummy/app/assets/javascripts/application.js
@@ -13,3 +13,5 @@
//= require jquery
//= require jquery_ujs
//= require_tree .
+
+window.ranJS = true;
View
10 test/dummy/test/integration/javascript_capybara_test.rb
@@ -0,0 +1,10 @@
+require 'test_helper'
+
+class JavascriptCapybaraTest < ActionDispatch::IntegrationTest
+ javascript
+
+ test "the home page" do
+ visit "/"
+ wait_until { page.evaluate_script("window.ranJS") }
+ end
+end
View
2 test/test_helper.rb
@@ -10,7 +10,9 @@
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
require 'capybara_rails/basic'
+require 'capybara_rails/selenium'
class ActionDispatch::IntegrationTest
include CapybaraRails::Basic
+ include CapybaraRails::Selenium
end

0 comments on commit 3b63e1f

Please sign in to comment.