sus-fixtures-async-webdriver 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6d117bc1968ff83bc9c09fc192f096939e6359d446bd4528c027f65f8f3cffa4
4
+ data.tar.gz: 31bf4661190b95dc50faa87e7680adbd5ed6f9d8b9163a4bef72b516b2e598d4
5
+ SHA512:
6
+ metadata.gz: bc36d496b42921bf10368ea166cc69edfa42e1e607c7810bff0bb4e9521feaa87aa092baf7e7698d859028940b42962eca8fd85a4178d6949c2eb98764d41d39
7
+ data.tar.gz: 50734787e437a593fda343969b47b10bf480a38de0ce3f9a72495131c65583f43a58a7ebd6ba3a9abff7c4094655309b46185028b131249b46d1c8ebf1c554ac
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ require 'async/webdriver'
7
+ require 'async/webdriver/bridge/pool'
8
+
9
+ module Sus
10
+ module Fixtures
11
+ module Async
12
+ module WebDriver
13
+ module SessionContext
14
+ GUARD = Thread::Mutex.new
15
+
16
+ def self.pool
17
+ return @pool if @pool
18
+
19
+ GUARD.synchronize do
20
+ @pool ||= begin
21
+ ::Async::WebDriver::Bridge::Pool.new(
22
+ ::Async::WebDriver::Bridge.default
23
+ )
24
+ end
25
+ end
26
+ end
27
+
28
+ def session
29
+ @session ||= SessionContext.pool.session
30
+ end
31
+
32
+ def before
33
+ super
34
+
35
+ @session = nil
36
+ end
37
+
38
+ def after
39
+ if @session
40
+ SessionContext.pool.reuse(@session)
41
+ @session = nil
42
+ end
43
+
44
+ super
45
+ end
46
+
47
+ def navigate_to(path)
48
+ session.navigate_to(URI.join(bound_url, path))
49
+ end
50
+
51
+ def find_element(...)
52
+ session.find_element(::Async::WebDriver::Locator.wrap(...))
53
+ end
54
+
55
+ def find_elements(...)
56
+ session.find_elements(::Async::WebDriver::Locator.wrap(...))
57
+ end
58
+
59
+ class HaveElement
60
+ def initialize(locator)
61
+ @locator = locator
62
+ @predicate = nil
63
+ end
64
+
65
+ def and(predicate)
66
+ @predicate = predicate
67
+ self
68
+ end
69
+
70
+ def print(output)
71
+ output.write("have element ", :variable, @locator.inspect, :reset)
72
+
73
+ if @predicate
74
+ output.write(" and ", @predicate)
75
+ end
76
+ end
77
+
78
+ def call(assertions, subject)
79
+ assertions.nested(self) do |assertions|
80
+ element = subject.find_element(@locator)
81
+ assertions.assert(element, "have element")
82
+
83
+ @predicate&.call(assertions, element)
84
+ rescue ::Async::WebDriver::NoSuchElementError
85
+ assertions.assert(nil, "have element")
86
+ end
87
+ end
88
+ end
89
+
90
+ def have_element(...)
91
+ HaveElement.new(::Async::WebDriver::Locator.wrap(...))
92
+ end
93
+
94
+ class HaveProperty
95
+ def initialize(name, value)
96
+ @name = name
97
+ @value = value
98
+ end
99
+
100
+ def print(output)
101
+ output.write("have property ", :variable, @name.inspect, :reset, " ", :variable, @value.inspect, :reset)
102
+ end
103
+
104
+ def call(assertions, subject)
105
+ assertions.assert(subject.property(@name), "have property")
106
+ end
107
+ end
108
+
109
+ def have_properties(**properties)
110
+ predicates = properties.map do |key, value|
111
+ HaveProperty.new(key, value)
112
+ end
113
+
114
+ Sus::Have::All.new(predicates)
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ module Sus
7
+ module Fixtures
8
+ module Async
9
+ module WebDriver
10
+ VERSION = "0.1.0"
11
+ end
12
+ end
13
+ end
14
+ end
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2023, by Samuel Williams.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,27 @@
1
+ # Sus::Fixtures::Async::WebDriver
2
+
3
+ Provides test fixtures for [async-webdriver](https://github.com/socketry/async-webdriver).
4
+
5
+ [![Development Status](https://github.com/socketry/sus-fixtures-async-webdriver/workflows/Test/badge.svg)](https://github.com/socketry/sus-fixtures-async-webdriver/actions?workflow=Test)
6
+
7
+ ## Usage
8
+
9
+ See `examples/rack` for a full example.
10
+
11
+ ## Contributing
12
+
13
+ We welcome contributions to this project.
14
+
15
+ 1. Fork it.
16
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
17
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
18
+ 4. Push to the branch (`git push origin my-new-feature`).
19
+ 5. Create new Pull Request.
20
+
21
+ ### Developer Certificate of Origin
22
+
23
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
24
+
25
+ ### Contributor Covenant
26
+
27
+ This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sus-fixtures-async-webdriver
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Williams
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
14
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
15
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
16
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
17
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
18
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
19
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
20
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
21
+ sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
22
+ e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
23
+ XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
24
+ RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
25
+ tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
26
+ zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
27
+ xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
28
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
29
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
30
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
31
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
32
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
33
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
34
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
35
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
36
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
37
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
+ -----END CERTIFICATE-----
40
+ date: 2023-12-08 00:00:00.000000000 Z
41
+ dependencies:
42
+ - !ruby/object:Gem::Dependency
43
+ name: async-webdriver
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.3'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.3'
56
+ description:
57
+ email:
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/sus/fixtures/async/webdriver/session_context.rb
63
+ - lib/sus/fixtures/async/webdriver/version.rb
64
+ - license.md
65
+ - readme.md
66
+ homepage: https://github.com/socketry/sus-fixtures-async-webdriver/
67
+ licenses:
68
+ - MIT
69
+ metadata:
70
+ documentation_uri: https://socketry.github.io/sus-fixtures-async-webdriver/
71
+ funding_uri: https://github.com/sponsors/ioquatix
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '3.0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubygems_version: 3.4.10
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: A set of sus fixtures for writing integration tests.
91
+ test_files: []
metadata.gz.sig ADDED
Binary file