diff --git a/README.md b/README.md index 69f7a29..1e2870d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ require 'persistent_selenium/driver' 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 these two differences: diff --git a/lib/persistent_selenium/cli.rb b/lib/persistent_selenium/cli.rb index b91fa67..f305424 100644 --- a/lib/persistent_selenium/cli.rb +++ b/lib/persistent_selenium/cli.rb @@ -3,12 +3,17 @@ require 'persistent_selenium' module PersistentSelenium class CLI < Thor + include Thor::Actions + + def self.source_root + File.expand_path('../../../skel', __FILE__) + end + desc "start", "Start the server" method_options :port => PersistentSelenium.port, :browser => PersistentSelenium.browser def start require 'persistent_selenium/browser' require 'drb' - GC.disable PersistentSelenium.configure do |c| c.port = options[:port] @@ -25,6 +30,11 @@ module PersistentSelenium DRb.thread.join end + desc "install", "Install Cucumber hook for using persistent selenium" + def install + directory '.', '.' + end + default_task :start end end diff --git a/skel/features/support/persistent_selenium.rb b/skel/features/support/persistent_selenium.rb new file mode 100644 index 0000000..f774190 --- /dev/null +++ b/skel/features/support/persistent_selenium.rb @@ -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 +