How to use Capybara in pure Ruby (without Rails)?
Here's something that seems to work for me:
require 'rubygems'require 'capybara'require 'capybara/dsl'Capybara.run_server = falseCapybara.current_driver = :seleniumCapybara.app_host = 'http://www.google.com'module MyCapybaraTest class Test include Capybara::DSL def test_google visit('/') end endendt = MyCapybaraTest::Test.newt.test_google
It goes to show that even incorrect documentation lives forever. The Capybara README used to recommend to include Capybara in the global namespace, this is a really bad idea, and messes up any number of random things. You should include Capybara in your own module or class and use that instead.
Check out the README for current best practices.
Please check this CapybaraRspec101 example and fork it.
It's a small example for acceptance tests on http://www.hi5.com using from scratch:
- Capybara
- Rspec
- Selenium-webdriver
All instructions are in the repo