-
-
Save kivanio/365746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w[ rubygems sinatra haml ].each {|lib| require lib } | |
get '/' do | |
"Hello World! The time is now #{ Time.now }" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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