govuk_test 1.0.3 → 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: 05e8262a72d9a72888032efc0d539c6b67cc1ab20f984fa83d0c4475b7c41027
4
- data.tar.gz: ce409d8629bb16bd3cba10f9b51a00f87a6e7807069f3b5a38e88490cd01e1e8
3
+ metadata.gz: e879e0b4e1b39bcd4287be0ff735b5901eb53144c2cfca98a5024c1e82ce5253
4
+ data.tar.gz: 74ba5e2ccd6fd805be749f289281eb5d2d4030446d8ff2b3f191f53a1f374cae
5
5
  SHA512:
6
- metadata.gz: 600e6998e13e17bde1c8a1f54f5514cee7f33bac9f28ecff9145fc1889a626c654309cc2cb2320c784d7cc7904c409e8988d22db8f59732e2f4c26804c9cf41d
7
- data.tar.gz: f532be00b2274e2f88bedaf0e70cd3b611eb430ceec75c3e7259e386dab11e7799eb3665b169fb1bb1e96bbca1f89f3499888c14a171de62a8c945bd5e1b917c
6
+ metadata.gz: da484c3a777accc15e51e51f1221a5f3263c7d6b3d22fb4ce53e445b2dbd5607a02fdfa6477a0fd9b3db6af9ff44e71e13e735634052b5812ca6e5b247892e3b
7
+ data.tar.gz: 230861fa63836ce22c11eb2ef621bdc5be61ed5728059e2840369b072db637f12eb4f80bfb5128c135f6675851dcd96942ed2356cecaea22c7567f374b4a251c
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.6.6
@@ -7,6 +7,17 @@
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
+
10
21
  ## 1.0.3
11
22
 
12
23
  * Add Brakeman as a dependency.
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).
@@ -28,7 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "selenium-webdriver", ">= 3.142"
29
29
  spec.add_dependency "brakeman", "~> 4.6"
30
30
 
31
- spec.add_development_dependency "bundler", "~> 1.16"
32
- 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"
33
34
  spec.add_development_dependency "rspec"
34
35
  end
@@ -13,15 +13,21 @@ unless ENV["GOVUK_TEST_USE_SYSTEM_CHROMEDRIVER"]
13
13
  end
14
14
 
15
15
  module GovukTest
16
- def self.configure(chrome_options: nil)
17
- chrome_options ||= Selenium::WebDriver::Chrome::Options.new
18
- chrome_options.headless!
19
-
16
+ def self.configure
20
17
  Capybara.register_driver :headless_chrome do |app|
21
- Capybara::Selenium::Driver.new(app, browser: :chrome, options: chrome_options)
18
+ Capybara::Selenium::Driver.new(app,
19
+ browser: :chrome,
20
+ options: headless_chrome_selenium_options)
22
21
  end
23
22
 
24
23
  Capybara.javascript_driver = :headless_chrome
25
24
  Capybara.server = :puma, { Silent: true }
26
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
27
33
  end
@@ -1,3 +1,3 @@
1
1
  module GovukTest
2
- VERSION = "1.0.3"
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: 1.0.3
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-10-15 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
@@ -84,30 +84,44 @@ dependencies:
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '1.16'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '1.16'
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'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '10.0'
117
+ version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '10.0'
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rspec
113
127
  requirement: !ruby/object:Gem::Requirement