automation_helpers 4.0.1 → 4.1.1

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: 1b76d24db41e2d9211d253fe3985f632bf3ac56c6f2053a0932622eff9fab3dd
4
- data.tar.gz: 794c1192df35048a0e7f8d06b0a4043a3f7a207ad5ed00cf4039ebcd389c8219
3
+ metadata.gz: 154b3a0f5fc399e0c379455a963dd13d3094be200957ecff1740dccfdd75418c
4
+ data.tar.gz: ba4e03604da108f8a68661f3879f69180c4f35b27796cc41660a4ee51d25f47f
5
5
  SHA512:
6
- metadata.gz: 5eda215013852802b916764ff564844bb336f39d363fa241de875c1199f07e09b46860273741fead783abb068fefd8e734e10cd004c12720465b3719109313c5
7
- data.tar.gz: f875ff9b0c007eb72f3282222ff9fff1276561c82d3f0061bb0644b8ded894e6b8d466e127b26094379030300f080a11577e8baf96de58c3b0bf07fa9c03b0e8
6
+ metadata.gz: 7fc83981d84eabd3887d096b0ab415598aa5243b9027b6b0a8e1de2fb76520346db275fd9f51ea10642946646ae0319f214ab30af76fcc218fbe56c629c17165
7
+ data.tar.gz: 6cf8cf6feb9820e8b781d5830557d0d4aaf2ad1e5d370b2db1e0fb7ef8198a5fe012f67ae5d30184068eabb45cfeebaa053f6926cc99955239f5cdfe0cc378e3
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020-2022, The SitePrism team & Marcelo Nicolosi Santos
1
+ Copyright (c) 2020-2023, The SitePrism team & Marcelo Nicolosi Santos
2
2
 
3
3
  All rights reserved.
4
4
 
@@ -10,4 +10,4 @@ Redistributions in binary form must reproduce the above copyright notice, this l
10
10
 
11
11
  Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
12
 
13
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -29,6 +29,19 @@ $ bundle
29
29
 
30
30
  Either require all of the extensions required, or require individual bits and pieces
31
31
 
32
+ ```shell
33
+ # Require all of the drivers/patches/extensions code
34
+ require 'automation_helpers'
35
+ # Require all driver code
36
+ require 'automation_helpers/drivers'
37
+ # Require just local drivers
38
+ require 'automation_helpers/drivers/local'
39
+ # Require all patches
40
+ require 'automation_helpers/patches'
41
+ # Require all extensions
42
+ require 'automation_helpers/extensions'
43
+ ```
44
+
32
45
  ## Development
33
46
 
34
47
  ```
@@ -9,11 +9,9 @@ require 'automation_helpers/drivers/v4/options'
9
9
  module AutomationHelpers
10
10
  module Drivers
11
11
  module V4
12
- #
13
- # {AutomationHelpers::Drivers::V4::Browserstack}
14
12
  #
15
13
  # The Browserstack Driver that will connect to a hosted grid
16
- # Requires a series of pre-set values to be passed in
14
+ # This requires a series of pre-set values to be passed in
17
15
  #
18
16
  class Browserstack
19
17
  attr_reader :browser, :browserstack_options, :device_options
@@ -6,10 +6,7 @@ module AutomationHelpers
6
6
  module Drivers
7
7
  module V4
8
8
  #
9
- # {AutomationHelpers::Drivers::V4::Capabilities}
10
- #
11
- # The Capabilities object that will be used to instantiate whatever driver you
12
- # are configuring
9
+ # The Capabilities object that will be used to instantiate whatever driver you are configuring
13
10
  #
14
11
  class Capabilities
15
12
  class << self
@@ -29,6 +26,7 @@ module AutomationHelpers
29
26
  when :firefox; then firefox_capabilities
30
27
  when :internet_explorer; then internet_explorer_capabilities
31
28
  when :ios; then ios_capabilities(device_options)
29
+ when :safari; then safari_capabilities
32
30
  else {}
33
31
  end
34
32
  end
@@ -99,6 +97,14 @@ module AutomationHelpers
99
97
  else raise ArgumentError, "Your iOS Version is too low. Please don't use lower than iOS 11."
100
98
  end
101
99
  end
100
+
101
+ def safari_capabilities
102
+ AutomationHelpers.logger.warn('Altering Browser Name request to alleviate Capybara failure with STP.')
103
+
104
+ {
105
+ 'browserName' => 'Safari Technology Preview'
106
+ }
107
+ end
102
108
  end
103
109
  end
104
110
  end
@@ -7,8 +7,6 @@ require 'automation_helpers/drivers/v4/options'
7
7
  module AutomationHelpers
8
8
  module Drivers
9
9
  module V4
10
- #
11
- # {AutomationHelpers::Drivers::V4::Local}
12
10
  #
13
11
  # The Local Driver that will spin up and run on your machine (Without connecting to any grid)
14
12
  #
@@ -71,11 +69,10 @@ module AutomationHelpers
71
69
  #
72
70
  # NB: Whilst using Safari TP this is required.
73
71
  def desired_capabilities
74
- ::Selenium::WebDriver::Remote::Capabilities.new.tap do |capabilities|
75
- if safari?
76
- capabilities['browserName'] = 'Safari Technology Preview'
77
- AutomationHelpers.logger.warn('Altering Browser Name request to alleviate Capybara failure with STP.')
78
- end
72
+ if safari?
73
+ Capabilities.for(:safari)
74
+ else
75
+ ::Selenium::WebDriver::Remote::Capabilities.new
79
76
  end
80
77
  end
81
78
 
@@ -5,8 +5,6 @@ require 'selenium/webdriver'
5
5
  module AutomationHelpers
6
6
  module Drivers
7
7
  module V4
8
- #
9
- # {AutomationHelpers::Drivers::V4::Options}
10
8
  #
11
9
  # The Options object that will be used to instantiate whatever driver you
12
10
  # are configuring
@@ -6,11 +6,9 @@ require 'automation_helpers/drivers/v4/options'
6
6
  module AutomationHelpers
7
7
  module Drivers
8
8
  module V4
9
- #
10
- # {AutomationHelpers::Drivers::V4::Remote}
11
9
  #
12
10
  # The Remote Driver that will connect to a dockerised self-hosted grid
13
- # Expects the grid to be live and accepting node requests
11
+ # This expects the grid to be live **and** accepting node requests
14
12
  #
15
13
  class Remote
16
14
  attr_reader :browser
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'automation_helpers/logger'
4
+
3
5
  require 'automation_helpers/drivers/browserstack'
4
6
  require 'automation_helpers/drivers/local'
5
7
  require 'automation_helpers/drivers/remote'
@@ -2,11 +2,17 @@
2
2
 
3
3
  # Additional useful methods to extend the Array class with
4
4
  class Array
5
- # @return [Boolean]
5
+ # @return [Array]
6
6
  #
7
- # Test whether an array is wholly unique
8
- def uniq?
9
- uniq == self
7
+ # Generates an array of the english alphabet
8
+ # Accepts an input to determine what case of alphabet you want
9
+ def self.alphabet(type = :upper)
10
+ case type
11
+ when :upper; then ('A'..'Z').to_a
12
+ when :lower; then ('a'..'z').to_a
13
+ when :both; then ('a'..'z').to_a + ('A'..'Z').to_a
14
+ else raise ArgumentError, 'Invalid alphabet type. Must be :upper (default), :lower or :both'
15
+ end
10
16
  end
11
17
 
12
18
  # @return [Array]
@@ -15,4 +21,11 @@ class Array
15
21
  def non_uniq
16
22
  tally.select { |_key, count| count > 1 }.map(&:first)
17
23
  end
24
+
25
+ # @return [Boolean]
26
+ #
27
+ # Test whether an array is wholly unique
28
+ def uniq?
29
+ uniq == self
30
+ end
18
31
  end
@@ -4,7 +4,20 @@
4
4
  class String
5
5
  # @return [String]
6
6
  #
7
- # Convert's a regular string name into it's pascalized format
7
+ # Generates a single random letter from an array of the english alphabet
8
+ # Accepts an input to determine what case of alphabet you want
9
+ def self.alphabet_char(type = :upper)
10
+ case type
11
+ when :upper; then ('A'..'Z').to_a.sample
12
+ when :lower; then ('a'..'z').to_a.sample
13
+ when :both; then (('a'..'z').to_a + ('A'..'Z').to_a).sample
14
+ else raise ArgumentError, 'Invalid character type. Must be :upper (default), :lower or :both'
15
+ end
16
+ end
17
+
18
+ # @return [String]
19
+ #
20
+ # Converts a regular string name into it's pascalized format
8
21
  # This can then be used to generate a ClassName
9
22
  def pascalize
10
23
  split('_').map(&:capitalize).join
@@ -12,7 +25,15 @@ class String
12
25
 
13
26
  # @return [String]
14
27
  #
15
- # Convert's a regular string into a snake cased format
28
+ # Sanitize and convert every individual whitespace character to
29
+ # a regular space character (Does not sanitize newlines)
30
+ def sanitize_whitespace
31
+ gsub(/[ \t\r\f\u00A0]/, ' ')
32
+ end
33
+
34
+ # @return [String]
35
+ #
36
+ # Converts a regular string into a snake cased format
16
37
  # Will sanitize out some characters (Designed for titles)
17
38
  def snake_case
18
39
  gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
@@ -24,11 +45,10 @@ class String
24
45
  .downcase
25
46
  end
26
47
 
27
- # @return [String]
48
+ # @return [Boolean]
28
49
  #
29
- # Sanitize and convert every individual whitespace character to
30
- # a regular space character (Does not sanitize newlines)
31
- def sanitize_whitespace
32
- gsub(/[ \t\r\f\u00A0]/, ' ')
50
+ # Cast any string to true or false
51
+ def to_bool
52
+ %w[yes on true].include?(downcase)
33
53
  end
34
54
  end
@@ -7,6 +7,9 @@ module AutomationHelpers
7
7
  # @api private
8
8
  #
9
9
  class Logger
10
+ #
11
+ # Generate the Logger used in the gem
12
+ #
10
13
  def self.create(output = $stdout)
11
14
  logger = ::Logger.new(output)
12
15
  logger.progname = 'Automation Helpers'
@@ -2,9 +2,12 @@
2
2
 
3
3
  module AutomationHelpers
4
4
  module Patches
5
+ #
6
+ # @api private
7
+ #
5
8
  class Base
6
9
  #
7
- # api private (Not intended to be instantiated directly!)
10
+ # api private (Not intended to be instantiated directly! Use the child classes)
8
11
  #
9
12
  def patch!
10
13
  raise 'This is no longer supported' if prevent_usage?
@@ -24,6 +27,7 @@ module AutomationHelpers
24
27
  # From what point should this patch start throwing deprecation notices
25
28
  # If a date is provided, then after that date
26
29
  # If a version from is provided, then all releases after that one (NB: You must provide a link to the gem version)
30
+ # Otherwise the patch is considered never to be deprecated
27
31
  #
28
32
  def deprecate?
29
33
  if defined?(deprecation_notice_date)
@@ -39,6 +43,7 @@ module AutomationHelpers
39
43
  # From what point should this patch start preventing usage deprecation notices
40
44
  # If a date is provided, then after that date
41
45
  # If a version from is provided, then all releases after that one (NB: You must provide a link to the gem version)
46
+ # Otherwise the patch is considered never to be prevented from being used
42
47
  #
43
48
  def prevent_usage?
44
49
  if defined?(prevent_usage_date)
@@ -2,6 +2,9 @@
2
2
 
3
3
  module AutomationHelpers
4
4
  module Patches
5
+ #
6
+ # Fix the issue where the `#text` method doesn't normalize whitespace (Only the matchers do)
7
+ #
5
8
  class Capybara < Base
6
9
  private
7
10
 
@@ -18,6 +21,9 @@ module AutomationHelpers
18
21
  end
19
22
  end
20
23
 
24
+ #
25
+ # @api private
26
+ #
21
27
  module SafariTextPatch
22
28
  def text(type = nil, normalize_ws: ::Capybara.default_normalize_ws)
23
29
  super(type, normalize_ws: normalize_ws)
@@ -2,6 +2,9 @@
2
2
 
3
3
  module AutomationHelpers
4
4
  module Patches
5
+ #
6
+ # Fix the issue where the parser for parallel_tests doesn't permit the --retry flag (Or other flags at the end)
7
+ #
5
8
  class ParallelCucumber < Base
6
9
  private
7
10
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  module AutomationHelpers
4
4
  module Patches
5
+ #
6
+ # Fix the issue where the Selenium Logger isn't designed to parse characters that aren't standard ASCII
7
+ # (This is an issue in the parent Net-HTTP adapter that most loggers are built on)
8
+ #
5
9
  class SeleniumLogger < Base
6
10
  private
7
11
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  module AutomationHelpers
4
4
  module Patches
5
+ #
6
+ # Fix the issue where the `#convert_cookie` API private method in selenium-webdriver doesn't include the
7
+ # 'httpOnly' property in the returned cookie hash structure
8
+ #
5
9
  class SeleniumManager < Base
6
10
  private
7
11
 
@@ -29,6 +33,9 @@ module AutomationHelpers
29
33
  end
30
34
  end
31
35
 
36
+ #
37
+ # @api private
38
+ #
32
39
  module CookieConverter
33
40
  def convert_cookie(cookie)
34
41
  super(cookie)
@@ -2,6 +2,9 @@
2
2
 
3
3
  module AutomationHelpers
4
4
  module Patches
5
+ #
6
+ # Fix the issue where for some drivers selenium doesn't camelize the browser name key 'browserName' correctly
7
+ #
5
8
  class SeleniumOptions < Base
6
9
  def initialize(browser)
7
10
  @browser = browser
@@ -53,6 +56,9 @@ module AutomationHelpers
53
56
  end
54
57
  end
55
58
 
59
+ #
60
+ # @api private
61
+ #
56
62
  module CapabilitiesAsJsonFix
57
63
  private
58
64
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'automation_helpers/logger'
4
+
3
5
  require 'automation_helpers/patches/base'
4
6
  require 'automation_helpers/patches/capybara'
5
7
  require 'automation_helpers/patches/parallel_cucumber'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AutomationHelpers
4
- VERSION = '4.0.1'
4
+ VERSION = '4.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: automation_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Hill
@@ -9,29 +9,35 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-22 00:00:00.000000000 Z
12
+ date: 2023-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3.30'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '4'
21
24
  type: :development
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: '3.30'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '4'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: cucumber
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
38
  - - ">="
33
39
  - !ruby/object:Gem::Version
34
- version: '5.0'
40
+ version: '7.0'
35
41
  - - "<"
36
42
  - !ruby/object:Gem::Version
37
43
  version: '9'
@@ -41,7 +47,7 @@ dependencies:
41
47
  requirements:
42
48
  - - ">="
43
49
  - !ruby/object:Gem::Version
44
- version: '5.0'
50
+ version: '7.0'
45
51
  - - "<"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '9'
@@ -51,91 +57,97 @@ dependencies:
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '1.8'
60
+ version: '2.7'
55
61
  type: :development
56
62
  prerelease: false
57
63
  version_requirements: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '1.8'
67
+ version: '2.7'
62
68
  - !ruby/object:Gem::Dependency
63
69
  name: parallel_tests
64
70
  requirement: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - "~>"
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: '3.7'
75
+ - - "<"
76
+ - !ruby/object:Gem::Version
77
+ version: '5'
69
78
  type: :development
70
79
  prerelease: false
71
80
  version_requirements: !ruby/object:Gem::Requirement
72
81
  requirements:
73
- - - "~>"
82
+ - - ">="
74
83
  - !ruby/object:Gem::Version
75
84
  version: '3.7'
85
+ - - "<"
86
+ - !ruby/object:Gem::Version
87
+ version: '5'
76
88
  - !ruby/object:Gem::Dependency
77
89
  name: rspec
78
90
  requirement: !ruby/object:Gem::Requirement
79
91
  requirements:
80
92
  - - "~>"
81
93
  - !ruby/object:Gem::Version
82
- version: '3.10'
94
+ version: '3.12'
83
95
  type: :development
84
96
  prerelease: false
85
97
  version_requirements: !ruby/object:Gem::Requirement
86
98
  requirements:
87
99
  - - "~>"
88
100
  - !ruby/object:Gem::Version
89
- version: '3.10'
101
+ version: '3.12'
90
102
  - !ruby/object:Gem::Dependency
91
103
  name: rubocop
92
104
  requirement: !ruby/object:Gem::Requirement
93
105
  requirements:
94
106
  - - "~>"
95
107
  - !ruby/object:Gem::Version
96
- version: 1.35.0
108
+ version: 1.45.0
97
109
  type: :development
98
110
  prerelease: false
99
111
  version_requirements: !ruby/object:Gem::Requirement
100
112
  requirements:
101
113
  - - "~>"
102
114
  - !ruby/object:Gem::Version
103
- version: 1.35.0
115
+ version: 1.45.0
104
116
  - !ruby/object:Gem::Dependency
105
117
  name: rubocop-performance
106
118
  requirement: !ruby/object:Gem::Requirement
107
119
  requirements:
108
120
  - - "~>"
109
121
  - !ruby/object:Gem::Version
110
- version: 1.14.3
122
+ version: 1.18.0
111
123
  type: :development
112
124
  prerelease: false
113
125
  version_requirements: !ruby/object:Gem::Requirement
114
126
  requirements:
115
127
  - - "~>"
116
128
  - !ruby/object:Gem::Version
117
- version: 1.14.3
129
+ version: 1.18.0
118
130
  - !ruby/object:Gem::Dependency
119
131
  name: rubocop-rspec
120
132
  requirement: !ruby/object:Gem::Requirement
121
133
  requirements:
122
134
  - - "~>"
123
135
  - !ruby/object:Gem::Version
124
- version: 2.11.1
136
+ version: 2.22.0
125
137
  type: :development
126
138
  prerelease: false
127
139
  version_requirements: !ruby/object:Gem::Requirement
128
140
  requirements:
129
141
  - - "~>"
130
142
  - !ruby/object:Gem::Version
131
- version: 2.11.1
143
+ version: 2.22.0
132
144
  - !ruby/object:Gem::Dependency
133
145
  name: selenium-webdriver
134
146
  requirement: !ruby/object:Gem::Requirement
135
147
  requirements:
136
148
  - - ">="
137
149
  - !ruby/object:Gem::Version
138
- version: 4.0.0.beta2
150
+ version: '4.0'
139
151
  - - "<"
140
152
  - !ruby/object:Gem::Version
141
153
  version: '5'
@@ -145,7 +157,7 @@ dependencies:
145
157
  requirements:
146
158
  - - ">="
147
159
  - !ruby/object:Gem::Version
148
- version: 4.0.0.beta2
160
+ version: '4.0'
149
161
  - - "<"
150
162
  - !ruby/object:Gem::Version
151
163
  version: '5'
@@ -155,14 +167,14 @@ dependencies:
155
167
  requirements:
156
168
  - - "~>"
157
169
  - !ruby/object:Gem::Version
158
- version: '4.6'
170
+ version: '5.2'
159
171
  type: :development
160
172
  prerelease: false
161
173
  version_requirements: !ruby/object:Gem::Requirement
162
174
  requirements:
163
175
  - - "~>"
164
176
  - !ruby/object:Gem::Version
165
- version: '4.6'
177
+ version: '5.2'
166
178
  description: Automation Patches / Extensions that allow you to extend your Ruby-based
167
179
  testing frameworks
168
180
  email: