sus-fixtures-async-http 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: 1716b4f27d91b40199835a2c12cefc8e41b731ed0fa0546ba1462077a5146896
4
+ data.tar.gz: 8f6246a78b59bf3f992c4cd9c6a1573e913f69aff6a100b3f6c095c536357d9d
5
+ SHA512:
6
+ metadata.gz: 9835755194d42cc88b071ae3a24540717daf760991a24b9c4a228882930dc408b535cee524d3a595bbf1fe639038b1b0c97bf98e83c4096821457394a2e29586
7
+ data.tar.gz: 962151af4106d8d605fa5f4f74e137e3f7a742788383a51d550cc046948bb1dc99d7dfd0238133acf6684c800197fa14d8f1a9e45a4213ffe631dc7a730b7b21
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,83 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'sus/fixtures/async/reactor_context'
22
+
23
+ require 'async/http/server'
24
+ require 'async/http/client'
25
+ require 'async/http/endpoint'
26
+ require 'async/io/shared_endpoint'
27
+
28
+ module Sus::Fixtures::Async
29
+ module HTTP::ServerContext
30
+ include ReactorContext
31
+
32
+ def protocol
33
+ Async::HTTP::Protocol::HTTP1
34
+ end
35
+
36
+ def endpoint
37
+ Async::HTTP::Endpoint.parse('http://127.0.0.1:9294', timeout: 0.8, reuse_port: true, protocol: protocol)
38
+ end
39
+
40
+ def retries
41
+ 1
42
+ end
43
+
44
+ def app
45
+ Protocol::HTTP::Middleware::HelloWorld
46
+ end
47
+
48
+ def middleware
49
+ app
50
+ end
51
+
52
+ def server
53
+ Async::HTTP::Server.new(middleware, @bound_endpoint)
54
+ end
55
+
56
+ def client
57
+ @client
58
+ end
59
+
60
+ def before
61
+ # We bind the endpoint before running the server so that we know incoming connections will be accepted:
62
+ @bound_endpoint = Async::IO::SharedEndpoint.bound(endpoint)
63
+
64
+ # I feel a dedicated class might be better than this hack:
65
+ mock(@bound_endpoint) do |mock|
66
+ mock.replace(:protocol) {endpoint.protocol}
67
+ mock.replace(:scheme) {endpoint.scheme}
68
+ end
69
+
70
+ @server_task = Async do
71
+ server.run
72
+ end
73
+
74
+ @client = Async::HTTP::Client.new(endpoint, protocol: endpoint.protocol, retries: retries)
75
+ end
76
+
77
+ def after
78
+ @client&.close
79
+ @server_task&.stop
80
+ @bound_endpoint&.close
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ module Sus
22
+ module Fixtures
23
+ module Async
24
+ module HTTP
25
+ VERSION = "0.1.0"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1 @@
1
+ require_relative 'http/server_context'
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2022, 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,21 @@
1
+ # Sus::Fixtures::Async::HTTP
2
+
3
+ Provides a convenient fixture for running a web server.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ $ bundle add sus-fixtures-async-http
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ruby
14
+ include Sus::Fixtures::Async::HTTP::ServerContext
15
+
16
+ let(:response) {client.get("/")}
17
+
18
+ it 'can perform a reqeust' do
19
+ expect(response.read).to be == "Hello World!"
20
+ end
21
+ ```
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ u�aEQ<�#��'2��#Q �r�APw�H�� �$$�x=�vѱ8�[�4�)$�-X��*��Ϧ����=~t�XW� �h ɖ(t����a�ΰ#`rw/M����A���L��_�PG���~��h1$�Ϫ
2
+ 0H�0mBZ������OI�N��7��Cy=��c��O� ���\ޗ���ӳ�(M�Ez�gI,����9� ��Y3YwC�.AX�8��̤��(.��踴Wӽ���¿
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sus-fixtures-async-http
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
+ MjRaFw0zMjA4MDMwN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/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: 2022-08-24 00:00:00.000000000 Z
41
+ dependencies:
42
+ - !ruby/object:Gem::Dependency
43
+ name: sus
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 0.10.1
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 0.10.1
56
+ - !ruby/object:Gem::Dependency
57
+ name: sus-fixtures-async
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.1'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.1'
70
+ description:
71
+ email:
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/sus/fixtures/async/http.rb
77
+ - lib/sus/fixtures/async/http/server_context.rb
78
+ - lib/sus/fixtures/async/http/version.rb
79
+ - license.md
80
+ - readme.md
81
+ homepage: https://github.com/ioquatix/sus-fixtures-async
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ funding_uri: https://github.com/sponsors/ioquatix/
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 2.7.0
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.3.7
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Test fixtures for running in Async::HTTP.
105
+ test_files: []
metadata.gz.sig ADDED
Binary file