minitest-sus 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 519ea936c0c0a204223290984b2d6c7c852a92ee3ffc2b930d183b66e77ea9d1
4
+ data.tar.gz: ac3ca0c1346b34c931a0c7982509845c48456af0d1f4857a66829d4cd53991cd
5
+ SHA512:
6
+ metadata.gz: de792de78716e35bbffefece449cf0c83f898a42005089ba3d1dd6b87f7e1eb87fb6395d4e355489118ae0c652143f3051a0e6eb3a7d4ba80cf79f90d656bd23
7
+ data.tar.gz: d73fa1de9931a39f622e386c54a39ab3be3eb25a64e34acb7bb13f6182ad4d69c54116325dfdc401810b92dd511b3bdc7bba06bd629314c6676b209487e47d07
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,90 @@
1
+ # Getting Started
2
+
3
+ This guide explains how to use the `minitest-sus` gem to use [sus](https://github.com/socketry/sus) fixtures within [Minitest](https://github.com/minitest/minitest) tests.
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your project:
8
+
9
+ ``` bash
10
+ $ bundle add minitest-sus
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ A sus fixture is a plain module that exposes `before`, `after` and `around` hooks along with helper methods. `Minitest::Sus::Context` provides the small amount of glue Minitest is missing (an `around` chain and a `mock` method) so those fixtures work unchanged.
16
+
17
+ Include `Minitest::Sus::Context` into your test class **before** the fixtures. The fixtures must sit above the bridge in the ancestor chain, so ordering matters:
18
+
19
+ ``` ruby
20
+ require "minitest/autorun"
21
+ require "minitest/sus"
22
+
23
+ require "sus/fixtures/async/reactor_context"
24
+
25
+ class MyTest < Minitest::Test
26
+ include Minitest::Sus::Context
27
+ include Sus::Fixtures::Async::ReactorContext
28
+
29
+ def test_runs_inside_the_reactor
30
+ # The fixture's `around` hook wraps the whole test in a reactor:
31
+ refute_nil Async::Task.current
32
+ end
33
+ end
34
+ ```
35
+
36
+ The entire Minitest lifecycle (`setup`, the test method and `teardown`) runs inside the fixture's `around` block, so any reactor, server or client set up by the fixture is available throughout.
37
+
38
+ ### HTTP Server Fixture
39
+
40
+ `sus-fixtures-async-http` provides a server and client. It uses sus's `mock` API internally, which the bridge supplies, so it works without any changes:
41
+
42
+ ``` ruby
43
+ require "minitest/autorun"
44
+ require "minitest/sus"
45
+
46
+ require "sus/fixtures/async/http/server_context"
47
+
48
+ class ServerTest < Minitest::Test
49
+ include Minitest::Sus::Context
50
+ include Sus::Fixtures::Async::HTTP::ServerContext
51
+
52
+ def test_can_perform_a_request
53
+ response = client.get("/")
54
+
55
+ assert_equal 200, response.status
56
+ assert_equal "Hello World!", response.read
57
+ end
58
+ end
59
+ ```
60
+
61
+ You can override the fixture's helper methods (e.g. `app`, `url`, `protocol`) just like you would in sus, by defining them in your test class:
62
+
63
+ ``` ruby
64
+ class ApplicationTest < Minitest::Test
65
+ include Minitest::Sus::Context
66
+ include Sus::Fixtures::Async::HTTP::ServerContext
67
+
68
+ def app
69
+ Protocol::HTTP::Middleware.for do |request|
70
+ Protocol::HTTP::Response[200, {}, ["Hello from my app!"]]
71
+ end
72
+ end
73
+
74
+ def test_serves_the_application
75
+ response = client.get("/")
76
+
77
+ assert_equal "Hello from my app!", response.read
78
+ end
79
+ end
80
+ ```
81
+
82
+ ## Isolation
83
+
84
+ The bridge is opt-in per test class. Nothing about `Minitest::Test` is patched globally, so any test that does not include `Minitest::Sus::Context` is completely unaffected — no reactor is started and no hooks are installed.
85
+
86
+ ## Limitations
87
+
88
+ The bridge supports the fixture contract used by gems like `sus-fixtures-async` and `sus-fixtures-async-http`: module-level `include`, the `before`/`after`/`around` hooks, helper methods and `mock`.
89
+
90
+ It does not implement sus's class-level context DSL (`include_context`, shared contexts, `let`, `it`, nested `describe`/`context`), as those overlap with Minitest's own test model. Write your test methods and assertions using Minitest as usual.
@@ -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: Use sus fixtures within Minitest tests.
5
+ metadata:
6
+ documentation_uri: https://socketry.github.io/minitest-sus/
7
+ funding_uri: https://github.com/sponsors/ioquatix/
8
+ source_code_uri: https://github.com/socketry/minitest-sus.git
9
+ files:
10
+ - path: getting-started.md
11
+ title: Getting Started
12
+ description: This guide explains how to use the `minitest-sus` gem to use [sus](https://github.com/socketry/sus)
13
+ fixtures within [Minitest](https://github.com/minitest/minitest) tests.
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2026, by Samuel Williams.
5
+
6
+ module Minitest
7
+ module Sus
8
+ VERSION = "0.1.0"
9
+ end
10
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2026, by Samuel Williams.
5
+
6
+ require "minitest"
7
+
8
+ # We reuse sus's own mock implementation so that fixtures which rely on `mock`
9
+ # (e.g. sus-fixtures-async-http) work unchanged. It loads standalone.
10
+ require "sus/mock"
11
+
12
+ require_relative "sus/version"
13
+
14
+ module Minitest
15
+ # A bridge that lets sus fixtures (plain modules exposing `before`, `after`,
16
+ # `around`, helper methods and `mock`) be used inside Minitest tests.
17
+ module Sus
18
+ # Include this into a `Minitest::Test` subclass to host sus fixtures,
19
+ # *before* the fixtures themselves so they sit above it in the ancestor
20
+ # chain.
21
+ #
22
+ # It is opt-in per test class — nothing about Minitest::Test is patched
23
+ # globally, so tests that don't use it are completely unaffected.
24
+ #
25
+ # It is the terminal of the fixture hook chain: it mirrors `Sus::Base`'s
26
+ # `before`/`after`/`around` contract, bridges `mock`, and wraps the whole
27
+ # Minitest run (setup + test + teardown) in the `around` chain so fixtures
28
+ # such as the async reactor are active throughout.
29
+ #
30
+ # @example Use an async reactor fixture within a Minitest test:
31
+ # class MyTest < Minitest::Test
32
+ # include Minitest::Sus::Context
33
+ # include Sus::Fixtures::Async::ReactorContext
34
+ #
35
+ # def test_example
36
+ # Async::Task.current # We are running inside the reactor.
37
+ # end
38
+ # end
39
+ module Context
40
+ # A hook which is called before the test is executed. Fixtures override
41
+ # this and call `super`.
42
+ def before
43
+ end
44
+
45
+ # A hook which is called after the test is executed. Fixtures override
46
+ # this and call `super`.
47
+ # @parameter error [Exception | Nil] The error raised by the test, if any.
48
+ def after(error = nil)
49
+ end
50
+
51
+ # Wrap logic around the test being executed. This is the terminal
52
+ # implementation: it runs `before`, yields, then `after`. Fixtures
53
+ # override this and call `super(&block)` to compose.
54
+ def around(&block)
55
+ self.before
56
+
57
+ return block.call
58
+ rescue => error
59
+ raise
60
+ ensure
61
+ self.after(error)
62
+ end
63
+
64
+ # Bridge sus's `mock` API onto the Minitest instance. The first call
65
+ # upgrades the instance with `Sus::Mocks`, which also installs the
66
+ # `after` cleanup that clears the mocks.
67
+ # @parameter target [Object] The object to mock.
68
+ def mock(target, &block)
69
+ self.singleton_class.prepend(::Sus::Mocks)
70
+
71
+ # Redirect to the freshly prepended implementation:
72
+ self.mock(target, &block)
73
+ end
74
+
75
+ # Run the test, wrapping the entire Minitest lifecycle in the `around`
76
+ # chain so fixture state (reactor, server, client, ...) is available to
77
+ # setup, the test body and teardown alike.
78
+ def run
79
+ result = nil
80
+
81
+ around do
82
+ result = super
83
+ end
84
+
85
+ return result
86
+ end
87
+ end
88
+ end
89
+ end
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2026, 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,53 @@
1
+ # Minitest::Sus
2
+
3
+ Provides a bridge for using [sus](https://github.com/socketry/sus) fixtures within [Minitest](https://github.com/minitest/minitest) tests, e.g. `sus-fixtures-async` and `sus-fixtures-async-http`.
4
+
5
+ [![Development Status](https://github.com/socketry/minitest-sus/workflows/Test/badge.svg)](https://github.com/socketry/minitest-sus/actions?workflow=Test)
6
+
7
+ ## Usage
8
+
9
+ Please see the [project documentation](https://socketry.github.io/minitest-sus/) for more details.
10
+
11
+ - [Getting Started](https://socketry.github.io/minitest-sus/guides/getting-started/index) - This guide explains how to use the `minitest-sus` gem to use [sus](https://github.com/socketry/sus) fixtures within [Minitest](https://github.com/minitest/minitest) tests.
12
+
13
+ ## Releases
14
+
15
+ Please see the [project releases](https://socketry.github.io/minitest-sus/releases/index) for all releases.
16
+
17
+ ### v0.1.0
18
+
19
+ - Initial implementation of the Minitest ↔ sus fixtures bridge.
20
+
21
+ ## Contributing
22
+
23
+ We welcome contributions to this project.
24
+
25
+ 1. Fork it.
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
28
+ 4. Push to the branch (`git push origin my-new-feature`).
29
+ 5. Create new Pull Request.
30
+
31
+ ### Running Tests
32
+
33
+ To run the test suite:
34
+
35
+ ``` shell
36
+ bundle exec sus
37
+ ```
38
+
39
+ ### Making Releases
40
+
41
+ To make a new release:
42
+
43
+ ``` shell
44
+ bundle exec bake gem:release:patch # or minor or major
45
+ ```
46
+
47
+ ### Developer Certificate of Origin
48
+
49
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
50
+
51
+ ### Community Guidelines
52
+
53
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
data/releases.md ADDED
@@ -0,0 +1,5 @@
1
+ # Releases
2
+
3
+ ## v0.1.0
4
+
5
+ - Initial implementation of the Minitest ↔ sus fixtures bridge.
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-sus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Williams
8
+ bindir: bin
9
+ cert_chain:
10
+ - |
11
+ -----BEGIN CERTIFICATE-----
12
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
13
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
14
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
15
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
16
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
17
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
18
+ igKCAYEAomvSopQXQ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nCHyCaRVuKkrKjqhYCdmMBqCws
34
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
35
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
36
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
37
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
38
+ -----END CERTIFICATE-----
39
+ date: 1980-01-02 00:00:00.000000000 Z
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '5'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sus
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.31'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.31'
69
+ executables: []
70
+ extensions: []
71
+ extra_rdoc_files: []
72
+ files:
73
+ - context/getting-started.md
74
+ - context/index.yaml
75
+ - lib/minitest/sus.rb
76
+ - lib/minitest/sus/version.rb
77
+ - license.md
78
+ - readme.md
79
+ - releases.md
80
+ homepage: https://github.com/socketry/minitest-sus
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ documentation_uri: https://socketry.github.io/minitest-sus/
85
+ funding_uri: https://github.com/sponsors/ioquatix/
86
+ source_code_uri: https://github.com/socketry/minitest-sus.git
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: '3.3'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 4.0.10
102
+ specification_version: 4
103
+ summary: Use sus fixtures within Minitest tests.
104
+ test_files: []
metadata.gz.sig ADDED
Binary file