sus-fixtures-async-http 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e7272272c20a88d6753e4392968fdba12e49d4d9f76829ff8083c36cbe75bc6
4
- data.tar.gz: 706d1f590f248501e7ad7642f92796c7677ac54bc6f8e91b86acfef28f53dec5
3
+ metadata.gz: dd3f410d2f916037112c74ffc5b4c84f60f1c88412e8d0bf687667cc6c005a82
4
+ data.tar.gz: cc7177359a1732b55cbbb6ecb67d2b0f83de0b288a5dafe501b05e71f484f506
5
5
  SHA512:
6
- metadata.gz: c41cc744c499c0e07ddf94b86221304a33914ededd510f9f6a0084c37ec735a62115993005349fa9f71c8f22f9d1efe01e9f028dfc2c4fff58ae8ccf77935cc0
7
- data.tar.gz: 446348d7ac72dcab88e9c51828976fa8a93ba5ef70abaada6fe81ede8d200fb2556584f16a3632c406d3b49c54a1dbdd8c55e1ef7b980c3d4eb8580a0927c048
6
+ metadata.gz: 7f80fed8f250fb0068320ccdb4127c53ccaab56b837123636b858abfcd64273fd0c9e27e55b7be77f2c787894f84e88517568f438a4d82f425288f3f6411cda3
7
+ data.tar.gz: 5a6e3d62afe002b99ab2921ed157733fbd1353b865b9d066ec1c606a4d92c0dd6e03d6e3f01352a0d50f1d6fa2d0e4ae4ef77b8a84c7f77bcd808d619a83b8ed
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,5 +1,7 @@
1
- # Copyright, 2022, by Samuel Williams.
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('http://localhost:0', timeout: 0.8, reuse_port: true, protocol: protocol)
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
@@ -75,6 +108,8 @@ module Sus::Fixtures
75
108
  @client&.close
76
109
  @server_task&.stop
77
110
  @bound_endpoint&.close
111
+
112
+ super
78
113
  end
79
114
  end
80
115
  end
@@ -1,12 +1,14 @@
1
- # Copyright, 2022, by Samuel Williams.
2
- # Released under the MIT License.
1
+ # frozen_string_literal: true
3
2
 
4
- require 'sus/fixtures'
3
+ # Released under the MIT License.
4
+ # Copyright, 2022-2023, by Samuel Williams.
5
5
 
6
- module Sus::Fixtures
7
- module Async
8
- module HTTP
9
- VERSION = "0.2.3"
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
@@ -1,5 +1,7 @@
1
- # Copyright, 2022, by Samuel Williams.
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_relative 'http/server_context'
5
7
  require_relative 'http/version'
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.2.3
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: 2022-08-28 00:00:00.000000000 Z
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.3.7
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