sus-fixtures-async-http 0.2.2 → 0.3.0
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 +38 -2
- data/lib/sus/fixtures/async/http/version.rb +9 -7
- data/lib/sus/fixtures/async/http.rb +3 -1
- data/license.md +21 -0
- data/readme.md +23 -0
- data.tar.gz.sig +0 -0
- metadata +33 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd3f410d2f916037112c74ffc5b4c84f60f1c88412e8d0bf687667cc6c005a82
|
4
|
+
data.tar.gz: cc7177359a1732b55cbbb6ecb67d2b0f83de0b288a5dafe501b05e71f484f506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f80fed8f250fb0068320ccdb4127c53ccaab56b837123636b858abfcd64273fd0c9e27e55b7be77f2c787894f84e88517568f438a4d82f425288f3f6411cda3
|
7
|
+
data.tar.gz: 5a6e3d62afe002b99ab2921ed157733fbd1353b865b9d066ec1c606a4d92c0dd6e03d6e3f01352a0d50f1d6fa2d0e4ae4ef77b8a84c7f77bcd808d619a83b8ed
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,5 +1,7 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Released under the MIT License.
|
4
|
+
# Copyright, 2022-2023, by Samuel Williams.
|
3
5
|
|
4
6
|
require 'sus/fixtures/async/reactor_context'
|
5
7
|
|
@@ -18,8 +20,37 @@ module Sus::Fixtures
|
|
18
20
|
::Async::HTTP::Protocol::HTTP1
|
19
21
|
end
|
20
22
|
|
23
|
+
def url
|
24
|
+
'http://localhost:0'
|
25
|
+
end
|
26
|
+
|
27
|
+
def bound_urls
|
28
|
+
urls = []
|
29
|
+
|
30
|
+
@client_endpoint.each do |address_endpoint|
|
31
|
+
address = address_endpoint.address
|
32
|
+
|
33
|
+
host = address.ip_address
|
34
|
+
if address.ipv6?
|
35
|
+
host = "[#{host}]"
|
36
|
+
end
|
37
|
+
|
38
|
+
port = address.ip_port
|
39
|
+
|
40
|
+
urls << "#{endpoint.scheme}://#{host}:#{port}"
|
41
|
+
end
|
42
|
+
|
43
|
+
urls.sort!
|
44
|
+
|
45
|
+
return urls
|
46
|
+
end
|
47
|
+
|
48
|
+
def bound_url
|
49
|
+
bound_urls.first
|
50
|
+
end
|
51
|
+
|
21
52
|
def endpoint
|
22
|
-
::Async::HTTP::Endpoint.parse(
|
53
|
+
::Async::HTTP::Endpoint.parse(url, timeout: 0.8, reuse_port: true, protocol: protocol)
|
23
54
|
end
|
24
55
|
|
25
56
|
def retries
|
@@ -47,6 +78,8 @@ module Sus::Fixtures
|
|
47
78
|
end
|
48
79
|
|
49
80
|
def before
|
81
|
+
super
|
82
|
+
|
50
83
|
# We bind the endpoint before running the server so that we know incoming connections will be accepted:
|
51
84
|
@bound_endpoint = ::Async::IO::SharedEndpoint.bound(endpoint)
|
52
85
|
@client_endpoint = @bound_endpoint.local_address_endpoint
|
@@ -61,6 +94,7 @@ module Sus::Fixtures
|
|
61
94
|
mock.replace(:protocol) {endpoint.protocol}
|
62
95
|
mock.replace(:scheme) {endpoint.scheme}
|
63
96
|
mock.replace(:authority) {endpoint.authority}
|
97
|
+
mock.replace(:path) {endpoint.path}
|
64
98
|
end
|
65
99
|
|
66
100
|
@server_task = Async do
|
@@ -74,6 +108,8 @@ module Sus::Fixtures
|
|
74
108
|
@client&.close
|
75
109
|
@server_task&.stop
|
76
110
|
@bound_endpoint&.close
|
111
|
+
|
112
|
+
super
|
77
113
|
end
|
78
114
|
end
|
79
115
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
-
#
|
2
|
-
# Released under the MIT License.
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2022-2023, by Samuel Williams.
|
5
5
|
|
6
|
-
module Sus
|
7
|
-
module
|
8
|
-
module
|
9
|
-
|
6
|
+
module Sus
|
7
|
+
module Fixtures
|
8
|
+
module Async
|
9
|
+
module HTTP
|
10
|
+
VERSION = "0.3.0"
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
data/license.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2022-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,23 @@
|
|
1
|
+
# Sus::Fixtures::Async::HTTP
|
2
|
+
|
3
|
+
Provides a convenient fixture for running a web server.
|
4
|
+
|
5
|
+
[![Development Status](https://github.com/socketry/sus-fixtures-async-http/workflows/Test/badge.svg)](https://github.com/socketry/sus-fixtures-async-http/actions?workflow=Test)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
``` bash
|
10
|
+
$ bundle add sus-fixtures-async-http
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
``` ruby
|
16
|
+
include Sus::Fixtures::Async::HTTP::ServerContext
|
17
|
+
|
18
|
+
let(:response) {client.get("/")}
|
19
|
+
|
20
|
+
it 'can perform a reqeust' do
|
21
|
+
expect(response.read).to be == "Hello World!"
|
22
|
+
end
|
23
|
+
```
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,8 +37,22 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date:
|
40
|
+
date: 2023-02-10 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: async-http
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.54'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.54'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: async-io
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,6 +95,20 @@ dependencies:
|
|
81
95
|
- - "~>"
|
82
96
|
- !ruby/object:Gem::Version
|
83
97
|
version: '0.1'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: covered
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.20'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.20'
|
84
112
|
description:
|
85
113
|
email:
|
86
114
|
executables: []
|
@@ -90,6 +118,8 @@ files:
|
|
90
118
|
- lib/sus/fixtures/async/http.rb
|
91
119
|
- lib/sus/fixtures/async/http/server_context.rb
|
92
120
|
- lib/sus/fixtures/async/http/version.rb
|
121
|
+
- license.md
|
122
|
+
- readme.md
|
93
123
|
homepage: https://github.com/ioquatix/sus-fixtures-async
|
94
124
|
licenses:
|
95
125
|
- MIT
|
@@ -110,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
140
|
- !ruby/object:Gem::Version
|
111
141
|
version: '0'
|
112
142
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.4.6
|
114
144
|
signing_key:
|
115
145
|
specification_version: 4
|
116
146
|
summary: Test fixtures for running in Async::HTTP.
|
metadata.gz.sig
CHANGED
Binary file
|