capybara-selenium 0.0.3 → 0.0.4
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +17 -49
- data/lib/capybara_selenium.rb +29 -24
- data/lib/capybara_selenium/server/configurator.rb +16 -11
- data/lib/capybara_selenium/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6627dce1f034a041bd712a59a9a4c04630e60bb8
|
4
|
+
data.tar.gz: 91f0aac5ea218266ab0f7b278906fd5101296879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b7bb0d3ff96a9e218049237515626243418124fdd3fc723884ca440f1c4326b173380e70309516cdb8b8063bb51bbaa6e5f2e5d897be24f871c45923764b765
|
7
|
+
data.tar.gz: 8282d32ef4f71af945f9bc861789aacf770b8519f9536cb7df72c2cde5dc4fe2bb2cdc7184f7d4d0f16775efd5db50dc4afec82bc230d45c363ab10fdb66c4fd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,62 +27,30 @@ Or install it yourself as:
|
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
-
Supported
|
30
|
+
Supported application servers:
|
31
31
|
|
32
|
-
-
|
33
|
-
- [ ] Rails apps
|
32
|
+
- Modular sinatra apps (through config.ru)
|
34
33
|
|
35
|
-
|
34
|
+
Supported selenium servers:
|
35
|
+
|
36
|
+
- Remote selenium server
|
36
37
|
|
37
38
|
```ruby
|
38
39
|
# features/support/continous_integration.rb
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
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
|
data/lib/capybara_selenium.rb
CHANGED
@@ -14,33 +14,42 @@ module CapybaraSelenium
|
|
14
14
|
class Configurator
|
15
15
|
include AppServer
|
16
16
|
include SeleniumServer
|
17
|
-
attr_reader :driver
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
24
|
-
@app_server.apply
|
25
|
-
@driver = @selenium_server.apply
|
26
|
-
end
|
34
|
+
private
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
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
|
-
|
42
|
-
|
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
|
-
|
5
|
-
|
4
|
+
attr_accessor :config
|
5
|
+
|
6
|
+
def initialize(config)
|
7
|
+
@config = config
|
6
8
|
end
|
7
9
|
|
8
10
|
def configure(&block)
|
9
|
-
@
|
10
|
-
block.call @
|
11
|
+
@config = create_config
|
12
|
+
block.call @config
|
11
13
|
end
|
12
14
|
|
13
|
-
def method_missing(method)
|
14
|
-
if @
|
15
|
-
|
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
|
-
|
23
|
+
fail
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
21
27
|
private
|
22
28
|
|
23
|
-
def
|
29
|
+
def create_config
|
24
30
|
*modules, klass = self.class.to_s.split('::')
|
25
|
-
"#{modules.join('::')}::#{type_of
|
26
|
-
.constantize.new
|
31
|
+
"#{modules.join('::')}::#{type_of klass}Configuration".constantize.new
|
27
32
|
end
|
28
33
|
|
29
34
|
def type_of(klass)
|