From ad5d5c5d059f7aea95c4e6c92697b0bd4cf5041d Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 9 Jan 2015 11:40:19 -0500 Subject: [PATCH] Split up Cucumber and RSpec support --- lib/persistent_selenium/cucumber.rb | 8 ++++++++ lib/persistent_selenium/driver.rb | 9 ++------- lib/persistent_selenium/rspec.rb | 10 ++++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 lib/persistent_selenium/cucumber.rb create mode 100644 lib/persistent_selenium/rspec.rb diff --git a/lib/persistent_selenium/cucumber.rb b/lib/persistent_selenium/cucumber.rb new file mode 100644 index 0000000..51e305c --- /dev/null +++ b/lib/persistent_selenium/cucumber.rb @@ -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 diff --git a/lib/persistent_selenium/driver.rb b/lib/persistent_selenium/driver.rb index 8e81bcd..789f5b6 100644 --- a/lib/persistent_selenium/driver.rb +++ b/lib/persistent_selenium/driver.rb @@ -5,16 +5,11 @@ require 'capybara/selenium/driver' # make sure these classes exist on this end [ 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 - require 'persistent_selenium/drb' Capybara.register_driver :persistent_selenium do |app| + require 'drb' + service = DRb.start_service browser = DRbObject.new nil, PersistentSelenium.url diff --git a/lib/persistent_selenium/rspec.rb b/lib/persistent_selenium/rspec.rb new file mode 100644 index 0000000..62fe515 --- /dev/null +++ b/lib/persistent_selenium/rspec.rb @@ -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