capybara-selenium 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fd20b8b4b3bf89cf1437c09075e558735f7d9cd
4
- data.tar.gz: c783c285c0be5d82384bff1493f84dd5bb80a37f
3
+ metadata.gz: 6627dce1f034a041bd712a59a9a4c04630e60bb8
4
+ data.tar.gz: 91f0aac5ea218266ab0f7b278906fd5101296879
5
5
  SHA512:
6
- metadata.gz: 4aa5cea8f4b8583d935edb6cccc7bd8c1e695e6a2e0431b0b476cc8d10b0dd8057f1291f9977b5860eeee960013e6e7885a459ba503e3d3a3af4a7b0a75b4d7c
7
- data.tar.gz: ac4c54cd17254412c733e19576db7af95518c2d05eb26debf33044adb09cc9c3d8e5c70a29aa97cbc16d3e37fbb02031e5ef8a6765f4fc00049e8c873c45992f
6
+ metadata.gz: 4b7bb0d3ff96a9e218049237515626243418124fdd3fc723884ca440f1c4326b173380e70309516cdb8b8063bb51bbaa6e5f2e5d897be24f871c45923764b765
7
+ data.tar.gz: 8282d32ef4f71af945f9bc861789aacf770b8519f9536cb7df72c2cde5dc4fe2bb2cdc7184f7d4d0f16775efd5db50dc4afec82bc230d45c363ab10fdb66c4fd
@@ -1,3 +1,8 @@
1
+ ## 0.0.4
2
+
3
+ * Complete refactoring for `CapybaraSelenium::Configurator`
4
+ * Documentation updated
5
+
1
6
  ## 0.0.3
2
7
 
3
8
  * Fixed constant name `CapybaraSelenium::Configurator` instead of
data/README.md CHANGED
@@ -27,62 +27,30 @@ Or install it yourself as:
27
27
 
28
28
  ## Usage
29
29
 
30
- Supported applications:
30
+ Supported application servers:
31
31
 
32
- - [X] Modular sinatra apps (through config.ru)
33
- - [ ] Rails apps
32
+ - Modular sinatra apps (through config.ru)
34
33
 
35
- #### Option 1: Using a block in constructor call (Recommended)
34
+ Supported selenium servers:
35
+
36
+ - Remote selenium server
36
37
 
37
38
  ```ruby
38
39
  # features/support/continous_integration.rb
39
- CapybaraSelenium::Configurator.new do
40
- rack_app_server.configure do |config|
41
- config.host = ENV['CI_APP_SERVER_HOST'] || 'localhost'
42
- config.port = ENV['CI_APP_SERVER_PORT'] || 8080
43
- config.config_ru_path = File.expand_path(
40
+ APP_SERVER_HOST = ENV['CI_APP_SERVER_HOST'] || 'localhost'
41
+ APP_SERVER_PORT = ENV['CI_APP_SERVER_PORT'] || 8080
42
+ SELENIUM_SERVER_URL = ENV['CI_SELENIUM_SERVER_URL'] ||
43
+ 'http://127.0.0.1:4444/wd/hub'
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(
44
49
  File.join(__FILE__, '../web_app/config.ru'))
45
- end
46
-
47
- remote_selenium_server.configure do |config|
48
- config.server_url = ENV['CI_SELENIUM_SERVER_URL'] ||
49
- 'http://127.0.0.1:4444/wd/hub'
50
- config.capabilities = { browser_name: browser_name }
51
- end
52
- end.dispatch
53
- ```
54
-
55
- #### Option 2: Using instance methods
56
50
 
57
- ```ruby
58
- # features/support/continous_integration.rb
59
- module ContinousIntegration
60
- def driver_for(browser_name)
61
- @configurator = CapybaraSelenium::Configurator.new
62
- configure_rack_app_server
63
- configure_selenium_server(browser_name)
64
- @configurator.apply
65
- end
66
-
67
- def configure_rack_app_server
68
- @configurator.rack_app_server.configure do |config|
69
- config.host = ENV['CI_APP_SERVER_HOST'] || 'localhost'
70
- config.port = ENV['CI_APP_SERVER_PORT'] || 8080
71
- config.config_ru_path = File.expand_path(
72
- File.join(__FILE__, '../web_app/config.ru'))
73
- end
74
- end
75
-
76
- def configure_selenium_server(browser_name)
77
- @configurator.remote_selenium_server.configure do |config|
78
- config.server_url = ENV['CI_SELENIUM_SERVER_URL'] ||
79
- 'http://127.0.0.1:4444/wd/hub'
80
- config.capabilities = { browser_name: browser_name }
81
- end
82
- end
83
- end
84
-
85
- World(ContinousIntegration)
51
+ selenium_server.server_url = SELENIUM_SERVER_URL
52
+ selenium_server.capabilities = { browser_name: browser_name }
53
+ end.configure
86
54
  ```
87
55
 
88
56
  ## Contributing
@@ -14,33 +14,42 @@ module CapybaraSelenium
14
14
  class Configurator
15
15
  include AppServer
16
16
  include SeleniumServer
17
- attr_reader :driver
18
-
19
- def initialize(&block)
20
- define_singleton_method(:dispatch, block) if block_given?
17
+ attr_reader :driver, :app_server, :selenium_server
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
21
32
  end
22
33
 
23
- def apply
24
- @app_server.apply
25
- @driver = @selenium_server.apply
26
- end
34
+ private
27
35
 
28
- def method_missing(method, *args, &block)
29
- if method =~ /(.*)_app_server/
30
- @app_server ||= configurator :app_server, $1
31
- elsif method =~ /(.*)_selenium_server/
32
- @selenium_server ||= configurator :selenium_server, $1
33
- else
34
- raise
35
- end
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
36
41
  end
37
42
 
38
- private
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
39
49
 
40
50
  def configurator(server_type, configurator_type, &block)
41
- klass = self.class
42
- server_module = klass.classify(server_type)
43
- configurator_klass = klass.classify(configurator_type)
51
+ server_module = server_type.to_s.classify
52
+ configurator_klass = configurator_type.to_s.classify
44
53
  "CapybaraSelenium::#{server_module}::#{configurator_klass}Configurator"
45
54
  .constantize.new(configuration(server_module, configurator_klass))
46
55
  end
@@ -49,9 +58,5 @@ module CapybaraSelenium
49
58
  "CapybaraSelenium::#{server_module}::#{klass}Configuration"
50
59
  .constantize.new
51
60
  end
52
-
53
- def self.classify(type)
54
- ActiveSupport::Inflector.classify(type)
55
- end
56
61
  end
57
62
  end
@@ -1,29 +1,34 @@
1
1
  module CapybaraSelenium
2
2
  module Server
3
3
  class Configurator
4
- def initialize(configuration)
5
- @configuration = configuration
4
+ attr_accessor :config
5
+
6
+ def initialize(config)
7
+ @config = config
6
8
  end
7
9
 
8
10
  def configure(&block)
9
- @configuration = create_configuration
10
- block.call @configuration
11
+ @config = create_config
12
+ block.call @config
11
13
  end
12
14
 
13
- def method_missing(method)
14
- if @configuration.respond_to? method
15
- return @configuration.send(method)
15
+ def method_missing(method, *args, &_)
16
+ if @config.respond_to? method
17
+ if method =~ /(.*)=/
18
+ return @config.send method, args.first
19
+ else
20
+ return @config.send method
21
+ end
16
22
  else
17
- raise
23
+ fail
18
24
  end
19
25
  end
20
26
 
21
27
  private
22
28
 
23
- def create_configuration
29
+ def create_config
24
30
  *modules, klass = self.class.to_s.split('::')
25
- "#{modules.join('::')}::#{type_of(klass)}Configuration"
26
- .constantize.new
31
+ "#{modules.join('::')}::#{type_of klass}Configuration".constantize.new
27
32
  end
28
33
 
29
34
  def type_of(klass)
@@ -1,3 +1,3 @@
1
1
  module CapybaraSelenium
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Saenz Tagarro