sus-fixtures-async-http 0.11.0 → 0.12.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: f94ff88eb42debcc5eb56e473fdfa6a52166b669f6242c749bf63776bd9dadc9
4
- data.tar.gz: ed0c8fc27e8a94c8c827bc8e1a17bf230551bfd29c7ea9722d2f5f9c21d9b941
3
+ metadata.gz: a02a80acae8f8b6c8502986b21ca39d7e950dabfde21839d3632735213f11cc0
4
+ data.tar.gz: 1ae85d08937d7340805503b06f3559baaa3ebe7d70aca052bdb6216a508dab13
5
5
  SHA512:
6
- metadata.gz: b59cf0cae7ccf666984842e884979279e639243e5be7d4380249cb6df60e8734b0dcb82e1a6aa88811fa56fb6ead7afb871db1cddb04f13d44f284953d6dfaf7
7
- data.tar.gz: 8e75129db355cafbd6a8469737b84c52451f6b21aec977967236b92bd542b7693c8bfa43861287212e93af81f9b8895a27cf4ddfa374e452f0d290b0358844f1
6
+ metadata.gz: 9144f6a3c90fb80a07d1e5717591a47a6c73f001105241b3b4912d54a0a96f04383e9cc657190671ad8477295ac3f0672c48ed14bf285e6fef27d81793db62b8
7
+ data.tar.gz: 748af62b604a42f8b342e813502f2a372de16d0135e4c260b96141b95aa6f8d09fc7ecc11e361dbdc69389bfaeb64fdf5cd2897c801a9e3e86ac63b1104bd90a
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,147 @@
1
+ # Getting Started
2
+
3
+ This guide explains how to use the `sus-fixtures-async-http` gem to test HTTP clients and servers.
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your project:
8
+
9
+ ``` bash
10
+ $ bundle add sus-fixtures-async-http
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Here is a simple example showing how to test the default server:
16
+
17
+ ``` ruby
18
+ include Sus::Fixtures::Async::HTTP::ServerContext
19
+
20
+ let(:response) {client.get("/")}
21
+
22
+ it 'can perform a request' do
23
+ expect(response.read).to be == "Hello World!"
24
+ end
25
+ ```
26
+
27
+ ### Custom Applications
28
+
29
+ You can create a custom application to test your own HTTP handlers:
30
+
31
+ ``` ruby
32
+ include Sus::Fixtures::Async::HTTP::ServerContext
33
+
34
+ let(:app) do
35
+ Protocol::HTTP::Middleware.for do |request|
36
+ case request.path
37
+ when "/"
38
+ Protocol::HTTP::Response[200, {}, ["Home Page"]]
39
+ when "/api/status"
40
+ Protocol::HTTP::Response[200, {"content-type" => "application/json"}, ['{"status":"ok"}']]
41
+ else
42
+ Protocol::HTTP::Response[404, {}, ["Not Found"]]
43
+ end
44
+ end
45
+ end
46
+
47
+ it 'serves the home page' do
48
+ response = client.get("/")
49
+ expect(response.status).to be == 200
50
+ expect(response.read).to be == "Home Page"
51
+ end
52
+
53
+ it 'serves API endpoints' do
54
+ response = client.get("/api/status")
55
+ expect(response.status).to be == 200
56
+ expect(response.headers["content-type"]).to be == "application/json"
57
+ expect(response.read).to be == '{"status":"ok"}'
58
+ end
59
+
60
+ it 'returns 404 for unknown paths' do
61
+ response = client.get("/unknown")
62
+ expect(response.status).to be == 404
63
+ end
64
+ ```
65
+
66
+ ### Testing Different HTTP Methods
67
+
68
+ Test various HTTP methods and request bodies:
69
+
70
+ ``` ruby
71
+ include Sus::Fixtures::Async::HTTP::ServerContext
72
+
73
+ let(:app) do
74
+ Protocol::HTTP::Middleware.for do |request|
75
+ case [request.method, request.path]
76
+ when ["GET", "/users"]
77
+ Protocol::HTTP::Response[200, {}, ['[{"id":1,"name":"John"}]']]
78
+ when ["POST", "/users"]
79
+ body = request.body.read
80
+ Protocol::HTTP::Response[201, {}, ["Created: #{body}"]]
81
+ when ["PUT", "/users/1"]
82
+ body = request.body.read
83
+ Protocol::HTTP::Response[200, {}, ["Updated: #{body}"]]
84
+ when ["DELETE", "/users/1"]
85
+ Protocol::HTTP::Response[204, {}, [""]]
86
+ else
87
+ Protocol::HTTP::Response[404, {}, ["Not Found"]]
88
+ end
89
+ end
90
+ end
91
+
92
+ it 'handles GET requests' do
93
+ response = client.get("/users")
94
+ expect(response.status).to be == 200
95
+ end
96
+
97
+ it 'handles POST requests' do
98
+ response = client.post("/users", {}, ['{"name":"Alice"}'])
99
+ expect(response.status).to be == 201
100
+ expect(response.read).to be(:include?, "Alice")
101
+ end
102
+
103
+ it 'handles PUT requests' do
104
+ response = client.put("/users/1", {}, ['{"name":"Bob"}'])
105
+ expect(response.status).to be == 200
106
+ end
107
+
108
+ it 'handles DELETE requests' do
109
+ response = client.delete("/users/1")
110
+ expect(response.status).to be == 204
111
+ end
112
+ ```
113
+
114
+ ## Configuration Options
115
+
116
+ ### Custom URLs and Ports
117
+
118
+ Override the server URL and endpoint options:
119
+
120
+ ``` ruby
121
+ include Sus::Fixtures::Async::HTTP::ServerContext
122
+
123
+ let(:url) {"http://localhost:9999"}
124
+
125
+ let(:endpoint_options) do
126
+ {reuse_port: true, protocol: protocol, timeout: 30}
127
+ end
128
+
129
+ it 'uses custom configuration' do
130
+ expect(bound_url).to be(:include?, ":9999")
131
+ end
132
+ ```
133
+
134
+ ### Protocol Selection
135
+
136
+ Test with different HTTP protocol versions:
137
+
138
+ ``` ruby
139
+ include Sus::Fixtures::Async::HTTP::ServerContext
140
+
141
+ let(:protocol) {Async::HTTP::Protocol::HTTP2}
142
+
143
+ it 'uses HTTP/2 protocol' do
144
+ response = client.get("/")
145
+ expect(response).to have_attributes(version: "HTTP/2.0")
146
+ end
147
+ ```
@@ -0,0 +1,13 @@
1
+ # Automatically generated context index for Utopia::Project guides.
2
+ # Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
3
+ ---
4
+ description: Test fixtures for running in Async::HTTP.
5
+ metadata:
6
+ documentation_uri: https://socketry.github.io/sus-fixtures-async-http/
7
+ funding_uri: https://github.com/sponsors/ioquatix/
8
+ source_code_uri: https://github.com/socketry/sus-fixtures-async-http.git
9
+ files:
10
+ - path: getting-started.md
11
+ title: Getting Started
12
+ description: This guide explains how to use the `sus-fixtures-async-http` gem to
13
+ test HTTP clients and servers.
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2024, by Samuel Williams.
4
+ # Copyright, 2022-2025, by Samuel Williams.
5
5
 
6
6
  module Sus
7
7
  module Fixtures
8
8
  module Async
9
9
  module HTTP
10
- VERSION = "0.11.0"
10
+ VERSION = "0.12.0"
11
11
  end
12
12
  end
13
13
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2022-2025, by Samuel Williams.
5
5
 
6
6
  # @namespace
7
7
  module Sus
data/readme.md CHANGED
@@ -2,13 +2,60 @@
2
2
 
3
3
  Provides a convenient fixture for running a web server.
4
4
 
5
- [![Development Status](https://github.com/suspecting/sus-fixtures-async-http/workflows/Test/badge.svg)](https://github.com/suspecting/sus-fixtures-async-http/actions?workflow=Test)
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
6
 
7
7
  ## Usage
8
8
 
9
- Please see the [project documentation](https://suspecting.github.io/sus-fixtures-async-http/) for more details.
9
+ Please see the [project documentation](https://socketry.github.io/sus-fixtures-async-http/) for more details.
10
10
 
11
- - [Getting Started](https://suspecting.github.io/sus-fixtures-async-http/guides/getting-started/index) - This guide explains how to use the `sus-fixtures-async-http` gem to test HTTP clients and servers.
11
+ - [Getting Started](https://socketry.github.io/sus-fixtures-async-http/guides/getting-started/index) - This guide explains how to use the `sus-fixtures-async-http` gem to test HTTP clients and servers.
12
+
13
+ ## Releases
14
+
15
+ Please see the [project releases](https://socketry.github.io/sus-fixtures-async-http/releases/index) for all releases.
16
+
17
+ ### v0.12.0
18
+
19
+ - Add agent context.
20
+
21
+ ### v0.11.0
22
+
23
+ - 100% documentation coverage.
24
+ - Remove unused outer server task.
25
+
26
+ ### v0.10.0
27
+
28
+ - Make it easier to override endpoint options like `timeout`.
29
+ - Remove default connection timeout.
30
+
31
+ ### v0.9.1
32
+
33
+ - Remove default connection timeout.
34
+
35
+ ### v0.9.0
36
+
37
+ - Add optional `after(error)` argument.
38
+ - Add Getting Started guide.
39
+
40
+ ### v0.8.1
41
+
42
+ - Add a timeout to prevent hangs during `@client.close`.
43
+
44
+ ### v0.8.0
45
+
46
+ - Don't depend on `async-io` directly.
47
+
48
+ ### v0.7.0
49
+
50
+ - Pass through the timeout.
51
+
52
+ ### v0.6.0
53
+
54
+ - Expose `make_client` similar to `make_server`.
55
+
56
+ ### v0.5.0
57
+
58
+ - Fix `make_server` to use endpoint argument.
12
59
 
13
60
  ## Contributing
14
61
 
data/releases.md ADDED
@@ -0,0 +1,87 @@
1
+ # Releases
2
+
3
+ ## v0.12.0
4
+
5
+ - Add agent context.
6
+
7
+ ## v0.11.0
8
+
9
+ - 100% documentation coverage.
10
+ - Remove unused outer server task.
11
+
12
+ ## v0.10.0
13
+
14
+ - Make it easier to override endpoint options like `timeout`.
15
+ - Remove default connection timeout.
16
+
17
+ ## v0.9.1
18
+
19
+ - Remove default connection timeout.
20
+
21
+ ## v0.9.0
22
+
23
+ - Add optional `after(error)` argument.
24
+ - Add Getting Started guide.
25
+
26
+ ## v0.8.1
27
+
28
+ - Add a timeout to prevent hangs during `@client.close`.
29
+
30
+ ## v0.8.0
31
+
32
+ - Don't depend on `async-io` directly.
33
+
34
+ ## v0.7.0
35
+
36
+ - Pass through the timeout.
37
+
38
+ ## v0.6.0
39
+
40
+ - Expose `make_client` similar to `make_server`.
41
+
42
+ ## v0.5.0
43
+
44
+ - Fix `make_server` to use endpoint argument.
45
+
46
+ ## v0.4.0
47
+
48
+ - Add SSL support.
49
+ - Correct homepage in gemspec.
50
+
51
+ ## v0.3.0
52
+
53
+ - Sort bound URLs for more predictable tests.
54
+ - Add missing dependency on `async-http`.
55
+ - Expose url and bound\_urls.
56
+
57
+ ## v0.2.3
58
+
59
+ - Mock path on `client_endpoint`.
60
+
61
+ ## v0.2.2
62
+
63
+ - Fix timeout.
64
+
65
+ ## v0.2.1
66
+
67
+ - Fix `client_endpoint` and add tests.
68
+
69
+ ## v0.2.0
70
+
71
+ - Expose client endpoint.
72
+
73
+ ## v0.1.3
74
+
75
+ - Improve compatibility with simultaneous execution by using host-allocated ports.
76
+
77
+ ## v0.1.2
78
+
79
+ - Relax dependency.
80
+
81
+ ## v0.1.1
82
+
83
+ - Fix all the things.
84
+
85
+ ## v0.1.0
86
+
87
+ - Initial implementation.
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.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -85,18 +85,21 @@ executables: []
85
85
  extensions: []
86
86
  extra_rdoc_files: []
87
87
  files:
88
+ - context/getting-started.md
89
+ - context/index.yaml
88
90
  - lib/sus/fixtures/async/http.rb
89
91
  - lib/sus/fixtures/async/http/server_context.rb
90
92
  - lib/sus/fixtures/async/http/version.rb
91
93
  - license.md
92
94
  - readme.md
93
- homepage: https://github.com/suspecting/sus-fixtures-async-http
95
+ - releases.md
96
+ homepage: https://github.com/socketry/sus-fixtures-async-http
94
97
  licenses:
95
98
  - MIT
96
99
  metadata:
97
- documentation_uri: https://suspecting.github.io/sus-fixtures-async-http/
100
+ documentation_uri: https://socketry.github.io/sus-fixtures-async-http/
98
101
  funding_uri: https://github.com/sponsors/ioquatix/
99
- source_code_uri: https://github.com/suspecting/sus-fixtures-async-http.git
102
+ source_code_uri: https://github.com/socketry/sus-fixtures-async-http.git
100
103
  rdoc_options: []
101
104
  require_paths:
102
105
  - lib
@@ -111,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
114
  - !ruby/object:Gem::Version
112
115
  version: '0'
113
116
  requirements: []
114
- rubygems_version: 3.6.7
117
+ rubygems_version: 3.6.9
115
118
  specification_version: 4
116
119
  summary: Test fixtures for running in Async::HTTP.
117
120
  test_files: []
metadata.gz.sig CHANGED
Binary file