Skip to content

Instantly share code, notes, and snippets.

@kivanio
Forked from beccasaurus/app.rb
Created April 14, 2010 12:24
Show Gist options
  • Save kivanio/365746 to your computer and use it in GitHub Desktop.
Save kivanio/365746 to your computer and use it in GitHub Desktop.
%w[ rubygems sinatra haml ].each {|lib| require lib }
get '/' do
"Hello World! The time is now #{ Time.now }"
end
%w[ rubygems spec capybara capybara/dsl ].each {|lib| require lib }
require File.dirname(__FILE__) + '/app'
require File.dirname(__FILE__) + '/capybara_webdriver'
include Capybara
Capybara.app = Sinatra::Application
Capybara.current_driver = :selenium
use_selenium_driver :htmlunit
describe 'App' do
it 'should test stuff' do
100.times do
visit '/'
page.should have_content('Hello World')
end
end
end
def use_selenium_driver driver
$__capybara_selenium_driver_name = driver
end
def selenium_driver
$__capybara_selenium_driver_name || :htmlunit
end
def (Capybara::Driver::Selenium).driver
unless @driver
if selenium_driver == :htmlunit
@driver = Selenium::WebDriver.for :remote,
:url => 'http://localhost:4444/wd/hub',
:desired_capabilities => Selenium::WebDriver::Remote::Capabilities.htmlunit
else
@driver = Selenium::WebDriver.for selenium_driver
end
at_exit do
@driver.quit
end
end
@driver
end
java -jar selenium-server-standalone-2.0a2.jar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment