quke 0.2.5 → 0.2.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 +4 -4
- data/.config.example.yml +9 -0
- data/CHANGELOG.md +38 -0
- data/bin/console +5 -0
- data/bin/setup +0 -0
- data/lib/features/support/env.rb +8 -4
- data/lib/quke.rb +1 -0
- data/lib/quke/configuration.rb +24 -27
- data/lib/quke/driver_configuration.rb +292 -0
- data/lib/quke/driver_registration.rb +36 -66
- data/lib/quke/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d94d8f089c2a7e1386bf52be42889b4a18bf8bca
|
4
|
+
data.tar.gz: 4546c88f278d7f1e19bf4f10cfb3de2cd294f430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c221a3c871dd0bc9ac04468e4b68f9e13d0d708e08d637746b85118c26f74366cd022ab6a3a586f1fd33283d2911cd00158368a00d5780307f37029f7b89186d
|
7
|
+
data.tar.gz: 1723da3d054399594ffb377387ac17b0b0ae9fee84f701446d9219d1b1c26ecff446e10a2f26ea7279e171ab23fd343f03eebbb0777f9fdd4ee0c8c0a8f34ee1
|
data/.config.example.yml
CHANGED
@@ -25,6 +25,15 @@ pause: 1
|
|
25
25
|
# a detailed response.
|
26
26
|
stop_on_error: 1
|
27
27
|
|
28
|
+
# If you are running Quke behind a proxy you can configure the proxy details
|
29
|
+
# here. You'll need either the hostname or IP of the proxy server (don't include
|
30
|
+
# the http:// bit) and the port number (typically 8080). Currently proxy
|
31
|
+
# settings will only be applied if you are using the PhantomJS, Chrome or
|
32
|
+
# Firefox drivers.
|
33
|
+
proxy:
|
34
|
+
host: '10.10.2.70'
|
35
|
+
port: 8080
|
36
|
+
|
28
37
|
# If you select the browserstack driver, there are a number of options you
|
29
38
|
# can pass through to setup your browserstack tests, username and auth_key
|
30
39
|
# being the critical ones.
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,43 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [Unreleased](https://github.com/EnvironmentAgency/quke/tree/HEAD)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/EnvironmentAgency/quke/compare/v0.2.5...HEAD)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- focus label left against rspec tests stops all tests running [\#43](https://github.com/EnvironmentAgency/quke/issues/43)
|
10
|
+
|
11
|
+
## [v0.2.5](https://github.com/EnvironmentAgency/quke/tree/v0.2.5) (2016-11-28)
|
12
|
+
[Full Changelog](https://github.com/EnvironmentAgency/quke/compare/v0.2.4...v0.2.5)
|
13
|
+
|
14
|
+
**Closed issues:**
|
15
|
+
|
16
|
+
- Don't use driver as an assumption of running on CI [\#41](https://github.com/EnvironmentAgency/quke/issues/41)
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- Fix rspec focus label left in tests [\#44](https://github.com/EnvironmentAgency/quke/pull/44) ([Cruikshanks](https://github.com/Cruikshanks))
|
21
|
+
|
22
|
+
## [v0.2.4](https://github.com/EnvironmentAgency/quke/tree/v0.2.4) (2016-11-28)
|
23
|
+
[Full Changelog](https://github.com/EnvironmentAgency/quke/compare/v0.2.3...v0.2.4)
|
24
|
+
|
25
|
+
**Closed issues:**
|
26
|
+
|
27
|
+
- Launchy showing blank pages on error [\#39](https://github.com/EnvironmentAgency/quke/issues/39)
|
28
|
+
|
29
|
+
**Merged pull requests:**
|
30
|
+
|
31
|
+
- Change after\_hook error to use config not assume [\#42](https://github.com/EnvironmentAgency/quke/pull/42) ([Cruikshanks](https://github.com/Cruikshanks))
|
32
|
+
|
33
|
+
## [v0.2.3](https://github.com/EnvironmentAgency/quke/tree/v0.2.3) (2016-10-05)
|
34
|
+
[Full Changelog](https://github.com/EnvironmentAgency/quke/compare/v0.2.2...v0.2.3)
|
35
|
+
|
36
|
+
**Merged pull requests:**
|
37
|
+
|
38
|
+
- Fix Quke not loading .config.yml correctly [\#37](https://github.com/EnvironmentAgency/quke/pull/37) ([Cruikshanks](https://github.com/Cruikshanks))
|
39
|
+
- Update CHANGELOG.md [\#36](https://github.com/EnvironmentAgency/quke/pull/36) ([Cruikshanks](https://github.com/Cruikshanks))
|
40
|
+
|
3
41
|
## [v0.2.2](https://github.com/EnvironmentAgency/quke/tree/v0.2.2) (2016-10-05)
|
4
42
|
[Full Changelog](https://github.com/EnvironmentAgency/quke/compare/v0.2.1...v0.2.2)
|
5
43
|
|
data/bin/console
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'bundler/setup'
|
4
4
|
require 'quke'
|
5
|
+
require 'quke/version'
|
6
|
+
require 'quke/configuration'
|
7
|
+
require 'quke/cuke_runner'
|
8
|
+
require 'quke/driver_registration'
|
9
|
+
require 'quke/driver_configuration'
|
5
10
|
|
6
11
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
12
|
# with your gem easier. You can also use a different console, if you like.
|
data/bin/setup
CHANGED
File without changes
|
data/lib/features/support/env.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
require 'rspec/expectations'
|
2
2
|
require 'capybara/cucumber'
|
3
3
|
require 'site_prism'
|
4
|
-
require 'quke/driver_registration'
|
5
4
|
require 'quke/configuration'
|
5
|
+
require 'quke/driver_configuration'
|
6
|
+
require 'quke/driver_registration'
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
unless Quke::Quke.config.app_host.empty?
|
9
|
+
Capybara.app_host = Quke::Quke.config.app_host
|
10
|
+
end
|
9
11
|
|
10
|
-
|
12
|
+
driver_config = Quke::DriverConfiguration.new(Quke::Quke.config)
|
13
|
+
driver_reg = Quke::DriverRegistration.new(driver_config)
|
14
|
+
driver = driver_reg.register(Quke::Quke.config.driver)
|
11
15
|
|
12
16
|
Capybara.default_driver = driver
|
13
17
|
Capybara.javascript_driver = driver
|
data/lib/quke.rb
CHANGED
data/lib/quke/configuration.rb
CHANGED
@@ -104,25 +104,22 @@ module Quke #:nodoc:
|
|
104
104
|
@data['browserstack']
|
105
105
|
end
|
106
106
|
|
107
|
-
#
|
108
|
-
# Capybara::Poltergeist::Driver.new(app, options).
|
107
|
+
# Return the hash of +proxy+ server settings
|
109
108
|
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
def
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
inspector: true
|
125
|
-
}
|
109
|
+
# If your environment requires you to go via a proxy server you can
|
110
|
+
# configure Quke to use it by setting the +host+ and +port+ in your config
|
111
|
+
# file.
|
112
|
+
def proxy
|
113
|
+
@data['proxy']
|
114
|
+
end
|
115
|
+
|
116
|
+
# Return true if the +proxy: host+ value has been set in the +.config.yml+
|
117
|
+
# file, else false.
|
118
|
+
#
|
119
|
+
# It is mainly used when determining whether to apply proxy server settings
|
120
|
+
# to the different drivers when registering them with Capybara.
|
121
|
+
def use_proxy?
|
122
|
+
proxy['host'] == '' ? false : true
|
126
123
|
end
|
127
124
|
|
128
125
|
# Override to_s to output the contents of Config as a readable string rather
|
@@ -133,18 +130,10 @@ module Quke #:nodoc:
|
|
133
130
|
|
134
131
|
private
|
135
132
|
|
136
|
-
def phantomjs_options
|
137
|
-
# Don't load images to help speed up the tests,
|
138
|
-
[
|
139
|
-
'--load-images=no',
|
140
|
-
'--disk-cache=false',
|
141
|
-
'--ignore-ssl-errors=yes'
|
142
|
-
]
|
143
|
-
end
|
144
|
-
|
145
133
|
def load_data
|
146
134
|
data = default_data!(load_yml_data)
|
147
135
|
data['browserstack'] = browserstack_data(data['browserstack'])
|
136
|
+
data['proxy'] = proxy_data(data['proxy'])
|
148
137
|
data
|
149
138
|
end
|
150
139
|
|
@@ -176,6 +165,14 @@ module Quke #:nodoc:
|
|
176
165
|
end
|
177
166
|
# rubocop:enable Metrics/MethodLength
|
178
167
|
|
168
|
+
def proxy_data(data)
|
169
|
+
data = {} if data.nil?
|
170
|
+
data.merge(
|
171
|
+
'host' => (data['host'] || '').downcase.strip,
|
172
|
+
'port' => (data['port'] || '0').to_s.downcase.strip.to_i
|
173
|
+
)
|
174
|
+
end
|
175
|
+
|
179
176
|
def load_yml_data
|
180
177
|
if File.exist? self.class.file_location
|
181
178
|
# YAML.load_file returns false if the file exists but is empty. So
|
@@ -0,0 +1,292 @@
|
|
1
|
+
require 'quke/configuration'
|
2
|
+
|
3
|
+
module Quke #:nodoc:
|
4
|
+
|
5
|
+
# Helper class that manages the options, switches and capabilities for each of
|
6
|
+
# the different drivers.
|
7
|
+
class DriverConfiguration
|
8
|
+
|
9
|
+
# Access the instance of Quke::Configuration passed to this instance of
|
10
|
+
# Quke::DriverOptions when it was initialized.
|
11
|
+
attr_reader :config
|
12
|
+
|
13
|
+
# Instantiate an instance of Quke::DriverConfiguration.
|
14
|
+
#
|
15
|
+
# It expects an instance of Quke::Configuration which will be used
|
16
|
+
# internally to determine how to set the options it passes back to each of
|
17
|
+
# the drivers.
|
18
|
+
# to be used and any related options
|
19
|
+
def initialize(config)
|
20
|
+
@config = config
|
21
|
+
end
|
22
|
+
|
23
|
+
# The hash returned from this method is intended to used when initialising
|
24
|
+
# an instance of Capybara::Poltergeist::Driver.
|
25
|
+
#
|
26
|
+
# For example when initialising the driver like this
|
27
|
+
#
|
28
|
+
# Capybara::Poltergeist::Driver.new(app,
|
29
|
+
# {
|
30
|
+
# js_errors: true,
|
31
|
+
# timeout: 30,
|
32
|
+
# debug: false,
|
33
|
+
# phantomjs_options: [
|
34
|
+
# '--load-images=no',
|
35
|
+
# '--disk-cache=false',
|
36
|
+
# '--ignore-ssl-errors=yes',
|
37
|
+
# '--proxy=10.10.2.70:8080'
|
38
|
+
# ],
|
39
|
+
# inspector: true
|
40
|
+
# }
|
41
|
+
# )
|
42
|
+
#
|
43
|
+
# Rather than setting the options manually
|
44
|
+
# Quke::DriverConfiguration.poltergeist is intended to manage what they
|
45
|
+
# should be based on the properties of the Quke::Configuration instance its
|
46
|
+
# initialised with
|
47
|
+
#
|
48
|
+
# Capybara::Poltergeist::Driver.new(app, my_driver_config.poltergeist)
|
49
|
+
#
|
50
|
+
def poltergeist
|
51
|
+
{
|
52
|
+
# Javascript errors will get re-raised in our tests causing them to fail
|
53
|
+
js_errors: true,
|
54
|
+
# How long in seconds we'll wait for response when communicating with
|
55
|
+
# Phantomjs
|
56
|
+
timeout: 30,
|
57
|
+
# When true debug output will be logged to STDERR (a terminal thing!)
|
58
|
+
debug: false,
|
59
|
+
# Poltergeist can pass on options for configuring phantomjs
|
60
|
+
phantomjs_options: phantomjs,
|
61
|
+
# The internet told me to put this here (???)
|
62
|
+
inspector: true
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns an array used as part of the poltergeist settings, which are
|
67
|
+
# passed in when initialising a Capybara::Poltergeist::Driver.
|
68
|
+
#
|
69
|
+
# For example when initialising the driver like this
|
70
|
+
#
|
71
|
+
# Capybara::Poltergeist::Driver.new(app,
|
72
|
+
# {
|
73
|
+
# js_errors: true,
|
74
|
+
# timeout: 30,
|
75
|
+
# debug: false,
|
76
|
+
# phantomjs_options: [
|
77
|
+
# '--load-images=no',
|
78
|
+
# '--disk-cache=false',
|
79
|
+
# '--ignore-ssl-errors=yes',
|
80
|
+
# '--proxy=10.10.2.70:8080'
|
81
|
+
# ],
|
82
|
+
# inspector: true
|
83
|
+
# }
|
84
|
+
# )
|
85
|
+
#
|
86
|
+
# Rather than setting the +phantomjs_options:+ manually
|
87
|
+
# Quke::DriverConfiguration.phantomjs
|
88
|
+
# is intended to manage what they should be based on the properties of the
|
89
|
+
# Quke::Configuration instance its initialised with
|
90
|
+
#
|
91
|
+
# Capybara::Poltergeist::Driver.new(app,
|
92
|
+
# {
|
93
|
+
# js_errors: true,
|
94
|
+
# timeout: 30,
|
95
|
+
# debug: false,
|
96
|
+
# phantomjs_options: my_driver_config.phantomjs,
|
97
|
+
# inspector: true
|
98
|
+
# }
|
99
|
+
# )
|
100
|
+
#
|
101
|
+
def phantomjs
|
102
|
+
options = [
|
103
|
+
'--load-images=no',
|
104
|
+
'--disk-cache=false',
|
105
|
+
'--ignore-ssl-errors=yes'
|
106
|
+
]
|
107
|
+
if config.use_proxy?
|
108
|
+
options.push("--proxy=#{config.proxy['host']}:#{config.proxy['port']}")
|
109
|
+
end
|
110
|
+
options
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns an array to be used in conjunction with the +:switches+ argument
|
114
|
+
# when initialising a Capybara::Selenium::Driver set for Chrome.
|
115
|
+
#
|
116
|
+
# For example when initialising the driver like this
|
117
|
+
#
|
118
|
+
# Capybara::Selenium::Driver.new(
|
119
|
+
# app,
|
120
|
+
# browser: :chrome,
|
121
|
+
# switches: ["--proxy-server=localhost:8080"]
|
122
|
+
# )
|
123
|
+
#
|
124
|
+
# Rather than setting the switches manually Quke::DriverConfiguration.chrome
|
125
|
+
# is intended to manage what they should be based on the properties of the
|
126
|
+
# Quke::Configuration instance its initialised with
|
127
|
+
#
|
128
|
+
# Capybara::Selenium::Driver.new(
|
129
|
+
# app,
|
130
|
+
# browser: :chrome,
|
131
|
+
# switches: my_driver_config.chrome
|
132
|
+
# )
|
133
|
+
#
|
134
|
+
def chrome
|
135
|
+
if config.use_proxy?
|
136
|
+
["--proxy-server=#{config.proxy['host']}:#{config.proxy['port']}"]
|
137
|
+
else
|
138
|
+
[]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns an instance of Selenium::WebDriver::Remote::Capabilities to be
|
143
|
+
# used when registering an instance of Capybara::Selenium::Driver,
|
144
|
+
# configured to run using Firefox (the default).
|
145
|
+
#
|
146
|
+
# For example when initialising the driver like this
|
147
|
+
#
|
148
|
+
# my_profile = Selenium::WebDriver::Firefox::Profile.new
|
149
|
+
# my_profile.proxy = Selenium::WebDriver::Proxy.new(
|
150
|
+
# http: "10.10.2.70:8080",
|
151
|
+
# ssl: "10.10.2.70:8080"
|
152
|
+
# )
|
153
|
+
# Capybara::Selenium::Driver.new(
|
154
|
+
# app,
|
155
|
+
# profile: my_profile
|
156
|
+
# )
|
157
|
+
#
|
158
|
+
# You can instead call Quke::DriverConfiguration.firefox which will
|
159
|
+
# manage instantiating and setting up the
|
160
|
+
# Selenium::WebDriver::Firefox::Profile instance based on the
|
161
|
+
# properties of the Quke::Configuration instance its initialised with
|
162
|
+
#
|
163
|
+
# Capybara::Selenium::Driver.new(
|
164
|
+
# app,
|
165
|
+
# profile: my_driver_config.firefox
|
166
|
+
# )
|
167
|
+
#
|
168
|
+
# rubocop:disable Metrics/AbcSize
|
169
|
+
def firefox
|
170
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
171
|
+
|
172
|
+
if config.use_proxy?
|
173
|
+
profile.proxy = Selenium::WebDriver::Proxy.new(
|
174
|
+
http: "#{config.proxy['host']}:#{config.proxy['port']}",
|
175
|
+
ssl: "#{config.proxy['host']}:#{config.proxy['port']}"
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
179
|
+
profile
|
180
|
+
end
|
181
|
+
# rubocop:enable Metrics/AbcSize
|
182
|
+
|
183
|
+
# Returns a string representing the url used when running tests via
|
184
|
+
# Browserstack[https://www.browserstack.com/] or nil.
|
185
|
+
#
|
186
|
+
# It will contain the username and auth_key set in the +.config.yml+, else
|
187
|
+
# if +username+ is blank it will return nil.
|
188
|
+
#
|
189
|
+
# An example return value
|
190
|
+
#
|
191
|
+
# "http://jdoe:123456789ABCDE@hub.browserstack.com/wd/hub"
|
192
|
+
#
|
193
|
+
# It is used when registering the driver with Capybara. So instead of this
|
194
|
+
#
|
195
|
+
# Capybara::Selenium::Driver.new(
|
196
|
+
# app,
|
197
|
+
# browser: :remote,
|
198
|
+
# url: 'http://jdoe:123456789ABCDE@hub.browserstack.com/wd/hub',
|
199
|
+
# desired_capabilities: my_capabilites
|
200
|
+
# )
|
201
|
+
#
|
202
|
+
# You can call +browserstack_url+ to get the url to use
|
203
|
+
#
|
204
|
+
# Capybara::Selenium::Driver.new(
|
205
|
+
# app,
|
206
|
+
# browser: :remote,
|
207
|
+
# url: my_driver_config.browserstack_url,
|
208
|
+
# desired_capabilities: my_capabilites
|
209
|
+
# )
|
210
|
+
#
|
211
|
+
def browserstack_url
|
212
|
+
username = config.browserstack['username']
|
213
|
+
key = config.browserstack['auth_key']
|
214
|
+
return "http://#{username}:#{key}@hub.browserstack.com/wd/hub" unless username == ''
|
215
|
+
end
|
216
|
+
|
217
|
+
# Returns an instance of Selenium::WebDriver::Remote::Capabilities to be
|
218
|
+
# used when registering an instance of Capybara::Selenium::Driver,
|
219
|
+
# configured to run using the Browserstack[https://www.browserstack.com/]
|
220
|
+
# service.
|
221
|
+
#
|
222
|
+
# For example when initialising the driver like this
|
223
|
+
#
|
224
|
+
# my_capabilites = Selenium::WebDriver::Remote::Capabilities.new
|
225
|
+
# my_capabilites['build'] = my_config.browserstack['build']
|
226
|
+
# # ... set rest of capabilities
|
227
|
+
# Capybara::Selenium::Driver.new(
|
228
|
+
# app,
|
229
|
+
# browser: :remote,
|
230
|
+
# url: 'http://jdoe:123456789ABCDE@hub.browserstack.com/wd/hub',
|
231
|
+
# desired_capabilities: my_capabilites
|
232
|
+
# )
|
233
|
+
#
|
234
|
+
# You can instead call Quke::DriverConfiguration.browserstack which will
|
235
|
+
# manage instantiating and setting up the
|
236
|
+
# Selenium::WebDriver::Remote::Capabilities instance based on the
|
237
|
+
# properties of the Quke::Configuration instance its initialised with
|
238
|
+
#
|
239
|
+
# Capybara::Selenium::Driver.new(
|
240
|
+
# app,
|
241
|
+
# browser: :remote,
|
242
|
+
# url: my_driver_config.browserstack_url,
|
243
|
+
# desired_capabilities: my_driver_config.browserstack
|
244
|
+
# )
|
245
|
+
#
|
246
|
+
# For further reference on browserstack capabilities
|
247
|
+
# https://www.browserstack.com/automate/capabilities
|
248
|
+
# https://www.browserstack.com/automate/ruby#configure-capabilities
|
249
|
+
# rubocop:disable Metrics/MethodLength
|
250
|
+
# rubocop:disable Metrics/AbcSize
|
251
|
+
def browserstack
|
252
|
+
capabilities = Selenium::WebDriver::Remote::Capabilities.new
|
253
|
+
|
254
|
+
capabilities['build'] = config.browserstack['build']
|
255
|
+
capabilities['project'] = config.browserstack['project']
|
256
|
+
capabilities['name'] = config.browserstack['name']
|
257
|
+
|
258
|
+
# This and the following section are essentially diametric; you set one
|
259
|
+
# or the other but not both. Some examples seem to put logic in place to
|
260
|
+
# test the options passed in and then set the capabilities accordingly,
|
261
|
+
# however Browserstack handles this and has what will happen documented
|
262
|
+
# https://www.browserstack.com/automate/capabilities#capabilities-parameter-override
|
263
|
+
capabilities['platform'] = config.browserstack['platform']
|
264
|
+
capabilities['browserName'] = config.browserstack['browserName']
|
265
|
+
capabilities['version'] = config.browserstack['version']
|
266
|
+
capabilities['device'] = config.browserstack['device']
|
267
|
+
|
268
|
+
capabilities['os'] = config.browserstack['os']
|
269
|
+
capabilities['os_version'] = config.browserstack['os_version']
|
270
|
+
capabilities['browser'] = config.browserstack['browser']
|
271
|
+
capabilities['browser_version'] = config.browserstack['browser_version']
|
272
|
+
capabilities['resolution'] = config.browserstack['resolution']
|
273
|
+
# -----
|
274
|
+
|
275
|
+
# This is not listed on the general capabilities page but is here
|
276
|
+
# https://www.browserstack.com/automate/ruby#self-signed-certificates
|
277
|
+
capabilities['acceptSslCerts'] = config.browserstack['acceptSslCerts']
|
278
|
+
|
279
|
+
capabilities['browserstack.debug'] = config.browserstack['debug']
|
280
|
+
capabilities['browserstack.video'] = config.browserstack['video']
|
281
|
+
|
282
|
+
# At this point Quke does not support local testing so we specifically
|
283
|
+
# tell Browserstack we're not doing this
|
284
|
+
capabilities['browserstack.local'] = 'false'
|
285
|
+
capabilities
|
286
|
+
end
|
287
|
+
# rubocop:enable Metrics/AbcSize
|
288
|
+
# rubocop:enable Metrics/MethodLength
|
289
|
+
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
@@ -8,30 +8,29 @@ module Quke #:nodoc:
|
|
8
8
|
# Capybara.
|
9
9
|
class DriverRegistration
|
10
10
|
|
11
|
-
# Access the instance of Quke::
|
12
|
-
# Quke::DriverRegistration when it was initialized.
|
11
|
+
# Access the instance of Quke::DriverConfiguration passed to this instance
|
12
|
+
# of Quke::DriverRegistration when it was initialized.
|
13
13
|
attr_reader :config
|
14
14
|
|
15
15
|
# Instantiate an instance of Quke::DriverRegistration.
|
16
16
|
#
|
17
|
-
# It expects an instance of Quke::
|
18
|
-
# to be used and any related options
|
17
|
+
# It expects an instance of Quke::DriverConfiguration which will detail the
|
18
|
+
# driver to be used and any related options
|
19
19
|
def initialize(config)
|
20
20
|
@config = config
|
21
21
|
end
|
22
22
|
|
23
|
-
# When called registers the driver specified
|
24
|
-
|
25
|
-
|
26
|
-
case @config.driver
|
23
|
+
# When called registers with Capybara the driver specified.
|
24
|
+
def register(driver)
|
25
|
+
case driver
|
27
26
|
when 'firefox'
|
28
27
|
firefox
|
29
28
|
when 'chrome'
|
30
29
|
chrome
|
31
30
|
when 'browserstack'
|
32
|
-
browserstack
|
31
|
+
browserstack
|
33
32
|
else
|
34
|
-
phantomjs
|
33
|
+
phantomjs
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
@@ -43,7 +42,7 @@ module Quke #:nodoc:
|
|
43
42
|
# it as :phantomjs. There are a number of options for how to configure
|
44
43
|
# poltergeist, and we can even pass on options to phantomjs to configure how
|
45
44
|
# it runs.
|
46
|
-
def phantomjs
|
45
|
+
def phantomjs
|
47
46
|
Capybara.register_driver :phantomjs do |app|
|
48
47
|
# We ignore the next line (and those like it in the subsequent methods)
|
49
48
|
# from code coverage because we never actually execute them from Quke.
|
@@ -52,7 +51,7 @@ module Quke #:nodoc:
|
|
52
51
|
# called, all we're doing here is telling it what block (code) to
|
53
52
|
# execute at that time.
|
54
53
|
# :simplecov_ignore:
|
55
|
-
Capybara::Poltergeist::Driver.new(app,
|
54
|
+
Capybara::Poltergeist::Driver.new(app, config.poltergeist)
|
56
55
|
# :simplecov_ignore:
|
57
56
|
end
|
58
57
|
:phantomjs
|
@@ -60,12 +59,15 @@ module Quke #:nodoc:
|
|
60
59
|
|
61
60
|
# Register the selenium driver with capybara. By default selinium is setup
|
62
61
|
# to work with firefox hence we refer to it as :firefox
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def firefox
|
63
|
+
# For future reference configuring Firefox via Selenium appears to be done
|
64
|
+
# via the profile argument, and a Selenium::WebDriver::Firefox::Profile
|
65
|
+
# object.
|
66
|
+
# https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings#firefox
|
67
|
+
# http://www.rubydoc.info/gems/selenium-webdriver/0.0.28/Selenium/WebDriver/Firefox/Profile
|
66
68
|
Capybara.register_driver :firefox do |app|
|
67
69
|
# :simplecov_ignore:
|
68
|
-
Capybara::Selenium::Driver.new(app)
|
70
|
+
Capybara::Selenium::Driver.new(app, profile: config.firefox)
|
69
71
|
# :simplecov_ignore:
|
70
72
|
end
|
71
73
|
:firefox
|
@@ -73,74 +75,42 @@ module Quke #:nodoc:
|
|
73
75
|
|
74
76
|
# Register the selenium driver again, only this time we are configuring it
|
75
77
|
# to work with chrome.
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
def chrome
|
79
|
+
# For future reference configuring Chrome via Selenium appears to be done
|
80
|
+
# use the switches argument, which I understand is essentially passed by
|
81
|
+
# Capybara to Selenium-webdriver, which in turn passes it to chromium
|
82
|
+
# https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings#chrome
|
83
|
+
# http://peter.sh/experiments/chromium-command-line-switches/
|
79
84
|
Capybara.register_driver :chrome do |app|
|
80
85
|
# :simplecov_ignore:
|
81
|
-
Capybara::Selenium::Driver.new(
|
86
|
+
Capybara::Selenium::Driver.new(
|
87
|
+
app,
|
88
|
+
browser: :chrome,
|
89
|
+
switches: config.chrome
|
90
|
+
)
|
82
91
|
# :simplecov_ignore:
|
83
92
|
end
|
84
93
|
:chrome
|
85
94
|
end
|
86
95
|
|
87
|
-
# Register a browserstack driver. Essentially this the selenium driver
|
88
|
-
# configured to run remotely using the Browserstack automate service.
|
89
|
-
# As a minimum the
|
90
|
-
# authenticate with Browserstack.
|
91
|
-
|
92
|
-
def browserstack(options = {})
|
96
|
+
# Register a browserstack driver. Essentially this is the selenium driver
|
97
|
+
# but configured to run remotely using the Browserstack automate service.
|
98
|
+
# As a minimum the +.config.yml+ must contain a username and auth_key in
|
99
|
+
# order to authenticate with Browserstack.
|
100
|
+
def browserstack
|
93
101
|
Capybara.register_driver :browserstack do |app|
|
94
102
|
# :simplecov_ignore:
|
95
|
-
username = options['username']
|
96
|
-
key = options['auth_key']
|
97
|
-
url = "http://#{username}:#{key}@hub.browserstack.com/wd/hub"
|
98
|
-
|
99
103
|
Capybara::Selenium::Driver.new(
|
100
104
|
app,
|
101
105
|
browser: :remote,
|
102
|
-
url:
|
103
|
-
desired_capabilities:
|
106
|
+
url: config.browserstack_url,
|
107
|
+
desired_capabilities: config.browserstack
|
104
108
|
)
|
105
109
|
# :simplecov_ignore:
|
106
110
|
end
|
107
111
|
:browserstack
|
108
112
|
end
|
109
113
|
|
110
|
-
# rubocop:disable Metrics/AbcSize
|
111
|
-
def browserstack_capabilities(options = {})
|
112
|
-
capabilities = Selenium::WebDriver::Remote::Capabilities.new
|
113
|
-
|
114
|
-
capabilities['build'] = options['build']
|
115
|
-
capabilities['project'] = options['project']
|
116
|
-
capabilities['name'] = options['name']
|
117
|
-
|
118
|
-
# This and the following section are essentially diametric; you set one
|
119
|
-
# or the other but not both. Some examples seen put logic in place to
|
120
|
-
# test the options passed in and then set the capabilities accordingly,
|
121
|
-
# however Browserstack handles this and has what will happen documented
|
122
|
-
# https://www.browserstack.com/automate/capabilities#capabilities-parameter-override
|
123
|
-
capabilities['platform'] = options['platform']
|
124
|
-
capabilities['browserName'] = options['browserName']
|
125
|
-
capabilities['version'] = options['version']
|
126
|
-
|
127
|
-
capabilities['os'] = options['os']
|
128
|
-
capabilities['os_version'] = options['os_version']
|
129
|
-
capabilities['browser'] = options['browser']
|
130
|
-
capabilities['browser_version'] = options['browser_version']
|
131
|
-
# -----
|
132
|
-
|
133
|
-
capabilities['browserstack.debug'] = options['debug']
|
134
|
-
capabilities['browserstack.video'] = options['video']
|
135
|
-
|
136
|
-
# At this point Quke does not support local testing so we specifically
|
137
|
-
# tell Browserstack we're not doing this
|
138
|
-
capabilities['browserstack.local'] = 'false'
|
139
|
-
capabilities
|
140
|
-
end
|
141
|
-
# rubocop:enable Metrics/AbcSize
|
142
|
-
# rubocop:enable Metrics/MethodLength
|
143
|
-
|
144
114
|
end
|
145
115
|
|
146
116
|
end
|
data/lib/quke/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Cruikshanks
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- lib/quke.rb
|
253
253
|
- lib/quke/configuration.rb
|
254
254
|
- lib/quke/cuke_runner.rb
|
255
|
+
- lib/quke/driver_configuration.rb
|
255
256
|
- lib/quke/driver_registration.rb
|
256
257
|
- lib/quke/version.rb
|
257
258
|
- quke.gemspec
|