Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save structuralartistry/738324 to your computer and use it in GitHub Desktop.
Save structuralartistry/738324 to your computer and use it in GitHub Desktop.
Add this code to Test/Unit test_helper.rb to be able to use Capybara in your integration tests
# This is working in a Rails 3/1.9.2 app
# For using Capybara in Test/Unit Integration tests -- majority of this taken from the tartare-rails gem
# Make sure you have the capybara gem installed -- gem install capybara
# You can also create a folder: Rails_root/test/integration/helpers and place Files within to abstract some of the Capybara steps....
require 'capybara/rails'
module ActionController
class IntegrationTest
include Capybara
Capybara.register_driver :selenium do |app|
Capybara::Driver::Selenium.new(app, :browser => :firefox)
end
Capybara.default_driver = :selenium
Capybara.ignore_hidden_elements = true
self.use_transactional_fixtures = false
# load integration test helpers
Dir.glob("test/integration/helpers/*.rb").each do |helper_file|
# for some reason the Dir.glob starts at rails root but when requiring, it starts within test/*
require helper_file.gsub(/test\//, '')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment