capybara-selenium 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27ac12b559b08c9451fbcfcf35c270ca9f082672
4
- data.tar.gz: 7a4d7119f936ee926a6ce89cd66c824da4b82f10
3
+ metadata.gz: 54318fe730391294e0641cf2de1d6380bd689b3d
4
+ data.tar.gz: dbdc0c6fa4ab296352d8406e7665914f816aa5cc
5
5
  SHA512:
6
- metadata.gz: 48e2b5fddebb1b124e2f1df4570bc5fcd96d375c5614752b2e923b412f091a14d90ef52aad249f0a030cc66eb68477d1967e2361b65cfdb52a36f99cc6de8e66
7
- data.tar.gz: 52e661a585a9f2ff926002791001f6f37206ceccba91e6f61df41b424c7b625e64e8dcfd5de4dd1984c8f0e640f6cf67e769bb39f49273dddd46007611e7e3f5
6
+ metadata.gz: 0029c1a01b9c432722c914dbf261ec60ee879974498704aad105a824ef4f9268f6f6832f456189b49b03d61ff65f03ab3024d8d130ff2fa02d05a33b71267091
7
+ data.tar.gz: 15d2051feff5361f02624814c378d4577027252bf54e7aeb39d1f18f73872aa79bcd0480d7da96c07e5736c4e1600781b3f2e9e944e60fad2de0f861155054b0
@@ -1,3 +1,9 @@
1
+ ## 0.0.6
2
+
3
+ * Syntax improvements for `CapybaraSelenium::SeleniumServer::RemoteConfigurator`
4
+ * Refactoring `configure` method call
5
+ * Documentation updated
6
+
1
7
  ## 0.0.5
2
8
 
3
9
  * Fixed capabilities for selenium remote server
data/README.md CHANGED
@@ -42,15 +42,15 @@ APP_SERVER_PORT = ENV['CI_APP_SERVER_PORT'] || 8080
42
42
  SELENIUM_SERVER_URL = ENV['CI_SELENIUM_SERVER_URL'] ||
43
43
  'http://127.0.0.1:4444/wd/hub'
44
44
 
45
- CapybaraSelenium::Configurator.new do |app_server, selenium_server|
46
- app_server.host = APP_SERVER_HOST
47
- app_server.port = APP_SERVER_PORT
48
- app_server.config_ru_path = File.expand_path(
45
+ CapybaraSelenium.configure(:rack, :remote) do |config|
46
+ config.app_server.host = APP_SERVER_HOST
47
+ config.app_server.port = APP_SERVER_PORT
48
+ config.app_server.config_ru_path = File.expand_path(
49
49
  File.join(__FILE__, '../web_app/config.ru'))
50
50
 
51
- selenium_server.server_url = SELENIUM_SERVER_URL
52
- selenium_server.capabilities = { browser_name: browser_name }
53
- end.configure
51
+ config.selenium_server.url = SELENIUM_SERVER_URL
52
+ config.selenium_server.capabilities = { browser_name: browser_name }
53
+ end
54
54
  ```
55
55
 
56
56
  ## Contributing
@@ -11,42 +11,25 @@ require 'active_support/inflector'
11
11
  module CapybaraSelenium
12
12
  # Class for configuring capybara and selenium in order to instance the
13
13
  # desired driver.
14
- class Configurator
14
+ class << self
15
15
  include AppServer
16
16
  include SeleniumServer
17
17
  attr_reader :driver, :app_server, :selenium_server
18
18
 
19
- # @param [Hash] opts The options for configuring servers
20
- # @option opts [String] :app_server The application server type. Default
21
- # :rack
22
- # @option opts [String] :selenium_server The selenium server type. Default
23
- # :remote
24
- def initialize(opts = {}, &block)
25
- @app_server = configurator :app_server, app_server_type(opts)
26
- @selenium_server = configurator :selenium_server, selenium_server_type(opts)
27
- define_singleton_method :configure do
28
- block.call(app_server, selenium_server)
29
- app_server.apply
30
- selenium_server.apply
31
- end
19
+ # @param app_server_type [Symbol] The application server type.
20
+ # Default: :rack
21
+ # @param selenium_server_type [Symbol The selenium server type.
22
+ # Default: :remote
23
+ def configure(app_server_type = :rack, selenium_server_type = :remote)
24
+ @app_server = configurator :app_server, app_server_type
25
+ @selenium_server = configurator :selenium_server, selenium_server_type
26
+ yield self
27
+ app_server.apply
28
+ selenium_server.apply
32
29
  end
33
30
 
34
31
  private
35
32
 
36
- # @param [Hash] opts The options for app server
37
- # @option opts [Symbol] :app_server The app server type
38
- # @return [String] The application server type
39
- def app_server_type(opts)
40
- opts[:app_server] || :rack
41
- end
42
-
43
- # @param [Hash] opts The options for selenium server
44
- # @option opts [Symbol] :selenium_server The selenium server type
45
- # @return [String] The selenium server type
46
- def selenium_server_type(opts)
47
- opts[:selenium_server] || :remote
48
- end
49
-
50
33
  def configurator(server_type, configurator_type, &block)
51
34
  server_module = server_type.to_s.classify
52
35
  configurator_klass = configurator_type.to_s.classify
@@ -1,11 +1,6 @@
1
1
  module CapybaraSelenium
2
2
  module SeleniumServer
3
3
  class BaseConfigurator < Server::Configurator
4
- private
5
-
6
- def caps(key)
7
- capabilities[key]
8
- end
9
4
  end
10
5
 
11
6
  class RemoteConfigurator < BaseConfigurator
@@ -22,14 +17,17 @@ module CapybaraSelenium
22
17
  end
23
18
 
24
19
  def driver_name
25
- "#{caps(:browser_name)}_#{caps(:version)}_#{caps(:platform)}"
20
+ browser_name = capabilities[:browser_name]
21
+ version = capabilities[:version]
22
+ platform = capabilities[:platform]
23
+ "#{browser_name}_#{version}_#{platform}"
26
24
  end
27
25
 
28
26
  # @return [Hash] The desired capabilities for the browser
29
27
  def desired_capabilities
30
- return @desired_capabilities if @desired_capabilities
31
- @desired_capabilities = Selenium::WebDriver::Remote::Capabilities
32
- .send(caps(:browser_name), capabilities)
28
+ caps = Selenium::WebDriver::Remote::Capabilities.new
29
+ capabilities.keys.each { |key| caps[key] = capabilities[key] }
30
+ caps
33
31
  end
34
32
  end
35
33
  end
@@ -1,3 +1,3 @@
1
1
  module CapybaraSelenium
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-selenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Saenz Tagarro