Compare commits

...

3 Commits

Author SHA1 Message Date
John Bintz
02b1e7553e Fixes for modern Capybara versions. 2015-01-09 14:56:22 -05:00
John Bintz
5e205ea347 Split up Cucumber and RSpec support 2015-01-09 14:55:26 -05:00
John Bintz
fdeb1b9eb5 Ensure browser type is initialized csafely 2015-01-09 11:32:16 -05:00
4 changed files with 31 additions and 8 deletions

View File

@ -5,7 +5,7 @@ require 'base64'
module PersistentSelenium module PersistentSelenium
class Browser < Capybara::Selenium::Driver class Browser < Capybara::Selenium::Driver
def initialize(browser_type) def initialize(browser_type)
@browser_type = browser_type @browser_type = browser_type.to_s.to_sym
@__found_elements__ = [] @__found_elements__ = []
end end
@ -30,6 +30,10 @@ module PersistentSelenium
{} {}
end end
def browser_initialized?
false
end
def visit(path) def visit(path)
if !path[/^http/] if !path[/^http/]
path = @app_host + path path = @app_host + path

View File

@ -0,0 +1,8 @@
require_relative './driver'
Before do
if Capybara.current_driver == :persistent_selenium
Capybara.server_port ||= '3001'
Capybara.app_host ||= "http://localhost:#{Capybara.server_port}"
end
end

View File

@ -4,16 +4,17 @@ require 'capybara/selenium/driver'
# make sure these classes exist on this end # make sure these classes exist on this end
[ Selenium::WebDriver::Error::StaleElementReferenceError, Selenium::WebDriver::Error::UnhandledError, Selenium::WebDriver::Error::ElementNotVisibleError ] [ Selenium::WebDriver::Error::StaleElementReferenceError, Selenium::WebDriver::Error::UnhandledError, Selenium::WebDriver::Error::ElementNotVisibleError ]
Before do
if Capybara.current_driver == :persistent_selenium
Capybara.server_port ||= '3001'
Capybara.app_host ||= "http://localhost:#{Capybara.server_port}"
end
end
Capybara.register_driver :persistent_selenium do |app| Capybara.register_driver :persistent_selenium do |app|
require 'drb' require 'drb'
module DRb
class DRbObject
def method(name)
method_missing(:method, name)
end
end
end
DRb.start_service DRb.start_service
browser = DRbObject.new nil, PersistentSelenium.url browser = DRbObject.new nil, PersistentSelenium.url

View File

@ -0,0 +1,10 @@
require_relative './driver'
RSpec.configure do |c|
c.before :each do
if Capybara.current_driver == :persistent_selenium
Capybara.server_port ||= '3001'
Capybara.app_host ||= "http://localhost:#{Capybara.server_port}"
end
end
end