govuk_test 0.5.0 → 2.0.0

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
  SHA256:
3
- metadata.gz: f7aa0bc205bc8af3b07ef3cc7dc46ddabc9a59a60035dd2997ae182b6050c99e
4
- data.tar.gz: bd0beb6fc201a1a7c773d19cb7dd50e7c78a7b6f7d9ce5cdf1c4dd727282e2f2
3
+ metadata.gz: e879e0b4e1b39bcd4287be0ff735b5901eb53144c2cfca98a5024c1e82ce5253
4
+ data.tar.gz: 74ba5e2ccd6fd805be749f289281eb5d2d4030446d8ff2b3f191f53a1f374cae
5
5
  SHA512:
6
- metadata.gz: c6a977ed71f33dc8c17511185747d8bc0b5b85e866544b6032760349b7aca5d7b410707f501b945efdadbc8984cc30e4a5b653bf77f8d424e99d6220f88dd866
7
- data.tar.gz: fa0c884c6e0177443431077b3b896e18ad27284c78d6820a42b6c158f016fda26f68929cb06959f62591f2c165a6f0906d7c7b6f39f418bd0b8fa26fec6b7a05
6
+ metadata.gz: da484c3a777accc15e51e51f1221a5f3263c7d6b3d22fb4ce53e445b2dbd5607a02fdfa6477a0fd9b3db6af9ff44e71e13e735634052b5812ca6e5b247892e3b
7
+ data.tar.gz: 230861fa63836ce22c11eb2ef621bdc5be61ed5728059e2840369b072db637f12eb4f80bfb5128c135f6675851dcd96942ed2356cecaea22c7567f374b4a251c
@@ -1 +1 @@
1
- 2.5.1
1
+ 2.6.6
@@ -7,6 +7,36 @@
7
7
  useful summary for people upgrading their application, not a replication
8
8
  of the commit log.
9
9
 
10
+ ## 2.0.0
11
+
12
+ * BREAKING: `.configure` no longer accepts options. If you need to modify the
13
+ headless_chrome selenium driver you can re-register the driver with
14
+ `Capybara.register_driver`.
15
+ * `GovukTest.headless_chrome_selenium_options` added to allow accessing the
16
+ headless Chrome selenium options for other contexts (such as configuring
17
+ Jasmine).
18
+ * `GOVUK_TEST_CHROME_NO_SANDBOX` can be set to default Chrome to be running
19
+ with the `--no-sandbox` argument.
20
+
21
+ ## 1.0.3
22
+
23
+ * Add Brakeman as a dependency.
24
+
25
+ ## 1.0.2
26
+
27
+ * Allow new versions of 'webdrivers' above 4
28
+
29
+ ## 1.0.1
30
+
31
+ * Ensure version of 'webdrivers' is at least 4
32
+
33
+ ## 1.0.0
34
+
35
+ * BREAKING: `.configure` accepts a `chrome_options` argument of an instance of
36
+ `Selenium::Webdriver::Chrome::Options` rather than a hash. The `window_size`
37
+ argument is dropped and can be done by configuring the `chrome_options`
38
+ instance, [example](https://github.com/alphagov/govuk_test/blob/dfd1a82e0114dbf1c668957fbea19cea04fd0d90/spec/govuk_test_spec.rb#L12-L22).
39
+
10
40
  ## 0.5.0
11
41
 
12
42
  * No changes: new release for semantic versioning purposes (0.4.4 should have been 0.5.0)
data/README.md CHANGED
@@ -5,36 +5,67 @@ Gem to package test dependencies and config for GOV.UK applications. Cousin of [
5
5
  ## Installation
6
6
 
7
7
  ```ruby
8
- gem 'govuk_test'
8
+ gem "govuk_test"
9
9
  ```
10
10
 
11
11
  And then execute:
12
12
 
13
- $ bundle
13
+ ```
14
+ $ bundle
15
+ ```
14
16
 
15
17
  ## Usage
16
18
 
17
- Somewhere in your `spec_helper`, `rails_helper`, or `spec/support/govuk_test.rb` put:
19
+ Somewhere in your `spec_helper.rb`, `rails_helper.rb`, or
20
+ `spec/support/govuk_test.rb` put:
18
21
 
19
- ```rb
22
+ ```ruby
20
23
  GovukTest.configure
21
24
  ```
22
25
 
23
- It's also possible to pass optional arguments `:chrome_options` and/or `:window_size `
24
- to `GovukTest.configure`:
26
+ This will configure [Capybara][] to run any JavaScript enabled tests
27
+ against a [Selenium][] driven instance of
28
+ [headless Google Chrome][headless-chrome].
25
29
 
26
- ```rb
27
- GovukTest.configure(chrome_options: { some_key: "some value" })
30
+ If you need to use this as a root user (such as within some docker containers)
31
+ you will need to set a `GOVUK_TEST_CHROME_NO_SANDBOX` environment variable.
28
32
 
29
- # or
33
+ You can reuse the Selenium options for headless Google Chrome for configuring
34
+ other Selenium driven tests, such as [Jasmine][]:
30
35
 
31
- GovukTest.configure(window_size: "1366,768")
36
+ ```ruby
37
+ class ChromeHeadlessJasmineConfigurer < JasmineSeleniumRunner::ConfigureJasmine
38
+ def selenium_options
39
+ { options: GovukTest.headless_chrome_selenium_options }
40
+ end
41
+ end
42
+ ```
32
43
 
33
- # or
44
+ Should you need to configure the options for your application the recommended
45
+ approach is to re-register the headless Google Chrome driver:
34
46
 
35
- GovukTest.configure(chrome_options: { some_key: "some value" }, window_size: "800,600")
47
+ ```ruby
48
+ GovukTest.configure
49
+
50
+ Capybara.register_driver :headless_chrome do |app|
51
+ chrome_options = GovukTest.headless_chrome_selenium_options
52
+ chrome_options.add_argument("--disable-web-security")
53
+ chrome_options.add_argument("--window-size=1400,1400")
54
+
55
+ Capybara::Selenium::Driver.new(
56
+ app,
57
+ browser: :chrome,
58
+ desired_capabilities: { acceptInsecureCerts: true },
59
+ options: chrome_options,
60
+ )
61
+ end
36
62
  ```
37
63
 
64
+ [Capybara]: https://github.com/teamcapybara/capybara
65
+ [Selenium]: https://selenium.dev
66
+ [headless-chrome]: https://developers.google.com/web/updates/2017/04/headless-chrome
67
+ [Jasmine]: https://github.com/jasmine/jasmine_selenium_runner
68
+
38
69
  ## License
39
70
 
40
71
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -23,11 +23,13 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "capybara"
26
- spec.add_dependency "webdrivers"
26
+ spec.add_dependency "webdrivers", ">= 4"
27
27
  spec.add_dependency "puma"
28
- spec.add_dependency "selenium-webdriver"
28
+ spec.add_dependency "selenium-webdriver", ">= 3.142"
29
+ spec.add_dependency "brakeman", "~> 4.6"
29
30
 
30
- spec.add_development_dependency "bundler", "~> 1.16"
31
- spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "bundler"
32
+ spec.add_development_dependency "climate_control"
33
+ spec.add_development_dependency "rake"
32
34
  spec.add_development_dependency "rspec"
33
35
  end
@@ -4,36 +4,30 @@ require "capybara"
4
4
  require "puma"
5
5
  require "selenium-webdriver"
6
6
 
7
- unless ENV['GOVUK_TEST_USE_SYSTEM_CHROMEDRIVER']
8
- require 'webdrivers'
7
+ unless ENV["GOVUK_TEST_USE_SYSTEM_CHROMEDRIVER"]
8
+ require "webdrivers"
9
9
 
10
10
  # This stop webdrivers doing a lazy check for new versions
11
11
  # of chromedriver, which interferes with WebMock.disable_net_connect
12
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
13
- Selenium::WebDriver::Chrome::Service.driver_path = Webdrivers::Chromedriver.update
14
- else
15
- Selenium::WebDriver::Chrome.driver_path = Webdrivers::Chromedriver.update
16
- end
12
+ Selenium::WebDriver::Chrome::Service.driver_path = Webdrivers::Chromedriver.update
17
13
  end
18
14
 
19
15
  module GovukTest
20
- def self.configure(options = {})
21
- chrome_options = %w(headless disable-gpu)
22
- chrome_options << "--window-size=#{options[:window_size]}" if options[:window_size]
23
-
16
+ def self.configure
24
17
  Capybara.register_driver :headless_chrome do |app|
25
- capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
26
- chromeOptions: { args: chrome_options }.merge(options.fetch(:chrome_options, {}))
27
- )
28
-
29
- Capybara::Selenium::Driver.new(
30
- app,
31
- browser: :chrome,
32
- desired_capabilities: capabilities
33
- )
18
+ Capybara::Selenium::Driver.new(app,
19
+ browser: :chrome,
20
+ options: headless_chrome_selenium_options)
34
21
  end
35
22
 
36
23
  Capybara.javascript_driver = :headless_chrome
37
24
  Capybara.server = :puma, { Silent: true }
38
25
  end
26
+
27
+ def self.headless_chrome_selenium_options
28
+ Selenium::WebDriver::Chrome::Options.new.tap do |options|
29
+ options.headless!
30
+ options.add_argument("--no-sandbox") if ENV["GOVUK_TEST_CHROME_NO_SANDBOX"]
31
+ end
32
+ end
39
33
  end
@@ -1,3 +1,3 @@
1
1
  module GovukTest
2
- VERSION = "0.5.0"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: puma
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,42 +58,70 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.142'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '3.142'
69
69
  - !ruby/object:Gem::Dependency
70
- name: bundler
70
+ name: brakeman
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.16'
76
- type: :development
75
+ version: '4.6'
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.16'
82
+ version: '4.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: climate_control
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: rake
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - "~>"
115
+ - - ">="
88
116
  - !ruby/object:Gem::Version
89
- version: '10.0'
117
+ version: '0'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - "~>"
122
+ - - ">="
95
123
  - !ruby/object:Gem::Version
96
- version: '10.0'
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: rspec
99
127
  requirement: !ruby/object:Gem::Requirement