sus-fixtures-async-http 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/sus/fixtures/async/http/server_context.rb +58 -71
- data/lib/sus/fixtures/async/http/version.rb +8 -25
- data/lib/sus/fixtures/async/http.rb +4 -0
- data.tar.gz.sig +0 -0
- metadata +2 -4
- metadata.gz.sig +0 -0
- data/license.md +0 -21
- data/readme.md +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c4568feda15d16a682baae23527d0cfde7a9a1d95c50b5a19796d7bf13c81e4
|
4
|
+
data.tar.gz: 78b17af438acaddcb8e0f1dbbfcd10071ae6d7335402eab80f3b0db708ed542d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f837069655f254e1c39f39207b43b8f5a7b6ea783b4f4c2b5ebde1d55fb8d6a1b5cf6fc1c21d764b99cc323340b49d6bdcc77726983498e7c3d11d624f14e4ae
|
7
|
+
data.tar.gz: bb78cb2f2d7ee560f67a2db190718f8e10c507de8aa5faa2d2612df2f888fac82d893f08fb2d572a0f4b30ae02216cf02ce5ac0502bb4a0fb52ed5face36aa56
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,22 +1,5 @@
|
|
1
|
-
# Copyright,
|
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.
|
1
|
+
# Copyright, 2022, by Samuel Williams.
|
2
|
+
# Released under the MIT License.
|
20
3
|
|
21
4
|
require 'sus/fixtures/async/reactor_context'
|
22
5
|
|
@@ -25,59 +8,63 @@ require 'async/http/client'
|
|
25
8
|
require 'async/http/endpoint'
|
26
9
|
require 'async/io/shared_endpoint'
|
27
10
|
|
28
|
-
module Sus::Fixtures
|
29
|
-
module
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
11
|
+
module Sus::Fixtures
|
12
|
+
module Async
|
13
|
+
module HTTP
|
14
|
+
module ServerContext
|
15
|
+
include ReactorContext
|
16
|
+
|
17
|
+
def protocol
|
18
|
+
::Async::HTTP::Protocol::HTTP1
|
19
|
+
end
|
20
|
+
|
21
|
+
def endpoint
|
22
|
+
::Async::HTTP::Endpoint.parse('http://127.0.0.1:9294', timeout: 0.8, reuse_port: true, protocol: protocol)
|
23
|
+
end
|
24
|
+
|
25
|
+
def retries
|
26
|
+
1
|
27
|
+
end
|
28
|
+
|
29
|
+
def app
|
30
|
+
::Protocol::HTTP::Middleware::HelloWorld
|
31
|
+
end
|
32
|
+
|
33
|
+
def middleware
|
34
|
+
app
|
35
|
+
end
|
36
|
+
|
37
|
+
def server
|
38
|
+
::Async::HTTP::Server.new(middleware, @bound_endpoint)
|
39
|
+
end
|
40
|
+
|
41
|
+
def client
|
42
|
+
@client
|
43
|
+
end
|
44
|
+
|
45
|
+
def before
|
46
|
+
# We bind the endpoint before running the server so that we know incoming connections will be accepted:
|
47
|
+
@bound_endpoint = ::Async::IO::SharedEndpoint.bound(endpoint)
|
48
|
+
|
49
|
+
# I feel a dedicated class might be better than this hack:
|
50
|
+
mock(@bound_endpoint) do |mock|
|
51
|
+
mock.replace(:protocol) {endpoint.protocol}
|
52
|
+
mock.replace(:scheme) {endpoint.scheme}
|
53
|
+
end
|
54
|
+
|
55
|
+
@server_task = Async do
|
56
|
+
server.run
|
57
|
+
end
|
58
|
+
|
59
|
+
@client = ::Async::HTTP::Client.new(endpoint, protocol: endpoint.protocol, retries: retries)
|
60
|
+
end
|
61
|
+
|
62
|
+
def after
|
63
|
+
@client&.close
|
64
|
+
@server_task&.stop
|
65
|
+
@bound_endpoint&.close
|
66
|
+
end
|
68
67
|
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
68
|
end
|
82
69
|
end
|
83
70
|
end
|
@@ -1,29 +1,12 @@
|
|
1
|
-
# Copyright,
|
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.
|
1
|
+
# Copyright, 2022, by Samuel Williams.
|
2
|
+
# Released under the MIT License.
|
20
3
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
4
|
+
require 'sus/fixtures'
|
5
|
+
|
6
|
+
module Sus::Fixtures
|
7
|
+
module Async
|
8
|
+
module HTTP
|
9
|
+
VERSION = "0.1.1"
|
27
10
|
end
|
28
11
|
end
|
29
12
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sus-fixtures-async-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date: 2022-08-
|
40
|
+
date: 2022-08-25 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: sus
|
@@ -76,8 +76,6 @@ files:
|
|
76
76
|
- lib/sus/fixtures/async/http.rb
|
77
77
|
- lib/sus/fixtures/async/http/server_context.rb
|
78
78
|
- lib/sus/fixtures/async/http/version.rb
|
79
|
-
- license.md
|
80
|
-
- readme.md
|
81
79
|
homepage: https://github.com/ioquatix/sus-fixtures-async
|
82
80
|
licenses:
|
83
81
|
- MIT
|
metadata.gz.sig
CHANGED
Binary file
|
data/license.md
DELETED
@@ -1,21 +0,0 @@
|
|
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
DELETED
@@ -1,21 +0,0 @@
|
|
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
|
-
```
|