add the ability to install a cucumber helper
This commit is contained in:
parent
15ac9af489
commit
5549ef5de4
@ -19,6 +19,12 @@ require 'persistent_selenium/driver'
|
|||||||
Capybara.default_driver = :persistent_selenium
|
Capybara.default_driver = :persistent_selenium
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you're using Cucumber, you can also install that hook:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
persistent_selenium install
|
||||||
|
```
|
||||||
|
|
||||||
Should work just the same as if you used the standard Capybara Selenium driver, except for
|
Should work just the same as if you used the standard Capybara Selenium driver, except for
|
||||||
these two differences:
|
these two differences:
|
||||||
|
|
||||||
|
@ -3,12 +3,17 @@ require 'persistent_selenium'
|
|||||||
|
|
||||||
module PersistentSelenium
|
module PersistentSelenium
|
||||||
class CLI < Thor
|
class CLI < Thor
|
||||||
|
include Thor::Actions
|
||||||
|
|
||||||
|
def self.source_root
|
||||||
|
File.expand_path('../../../skel', __FILE__)
|
||||||
|
end
|
||||||
|
|
||||||
desc "start", "Start the server"
|
desc "start", "Start the server"
|
||||||
method_options :port => PersistentSelenium.port, :browser => PersistentSelenium.browser
|
method_options :port => PersistentSelenium.port, :browser => PersistentSelenium.browser
|
||||||
def start
|
def start
|
||||||
require 'persistent_selenium/browser'
|
require 'persistent_selenium/browser'
|
||||||
require 'drb'
|
require 'drb'
|
||||||
GC.disable
|
|
||||||
|
|
||||||
PersistentSelenium.configure do |c|
|
PersistentSelenium.configure do |c|
|
||||||
c.port = options[:port]
|
c.port = options[:port]
|
||||||
@ -25,6 +30,11 @@ module PersistentSelenium
|
|||||||
DRb.thread.join
|
DRb.thread.join
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "install", "Install Cucumber hook for using persistent selenium"
|
||||||
|
def install
|
||||||
|
directory '.', '.'
|
||||||
|
end
|
||||||
|
|
||||||
default_task :start
|
default_task :start
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
11
skel/features/support/persistent_selenium.rb
Normal file
11
skel/features/support/persistent_selenium.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# get the driver ready for use
|
||||||
|
require 'persistent_selenium/driver'
|
||||||
|
|
||||||
|
# set it for all tests
|
||||||
|
# Capybara.default_driver = Capybara.javascript_driver = :persistent_selenium
|
||||||
|
#
|
||||||
|
# or, set it via the ENV, with it being the default
|
||||||
|
# Before do
|
||||||
|
# Capybara.default_driver = Capybara.javascript_driver = (ENV['DRIVER'] || 'persistent_selenium').to_sym
|
||||||
|
# end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user