angry_io 0.1.0 → 0.2.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: 8333b37ab325a405861724fec5d256e85255551879736909482389b3a203c14c
4
- data.tar.gz: 2b3f00b29dc6573e4ddf3ef33b7c91856ee49d56d31d2a0b0b293a59ca02adec
3
+ metadata.gz: e481e761566636d3cc9fcf965a2d5880a3b65e818cc1312c1c62897ccd6c16a1
4
+ data.tar.gz: 702fc8469bf85c8aec44fbfa861fcc86263b5bbb3bdb28b25338f26d3148caa7
5
5
  SHA512:
6
- metadata.gz: ef3525263035d341ada9c302472c468676a2196df6a1b57ed9b67d09e7c2d1bde7148dd18ca6fc6ed888e78bff6949ea97f4d645914d08e3a21094db77c306b4
7
- data.tar.gz: 3ca41798772a5e17b5406b4d70446edb08eedffb21f5c62c1115c22e849e1b397cbe3ea5dec41bf44e3b84da4fcc0fcfc5e565396294226d8fe922ab9bc72e54
6
+ metadata.gz: a862f0a1adf1077e3b7c6a43192692d22086e72f0761f7bd7629e13fc7b23908e798308ba969482b78d411686f34edee159544a2f93840d1391a18728f240c0a
7
+ data.tar.gz: 2ed4b06091d5afb5a9449e5fd3acd649995a09ee2e73ca8f4bf68b9f3cd27bef67d91959b4c2b9f503b1eec0847ff7b268d502e5c071fa11e866c11103a6ac18
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2026-09-04
4
+
5
+ - Remove the `angry_io/enable_for_ci_true` convenience require; require `angry_io/rspec` or `angry_io/minitest` directly instead.
6
+ - Remove the configurable `opt_out_metadata` field; the RSpec opt-out metadata is now always `:i_absolutely_need_to_write_to_stdout`.
7
+ - Adapters no longer swallow `LoadError` when their framework is missing; requiring an adapter now hard-requires its framework.
8
+
3
9
  ## [0.1.0] - 2026-09-04
4
10
 
5
11
  - Initial release
data/README.md CHANGED
@@ -4,15 +4,13 @@ Friends don't let friends write tests or specs that outputs to stdout/stderr. Wh
4
4
 
5
5
  AngryIo replaces `$stdout` and `$stderr` during your test suite with an IO that _raises on write_, so accidental output fails loudly instead of quietly cluttering your output. It ships self-registering adapters for both RSpec and Minitest, gated by a configurable `enabled` callable.
6
6
 
7
- The name and the default opt-out metadata are a nod to [minitest](https://github.com/minitest/minitest)'s `i_suck_and_my_tests_are_order_dependent!`.
8
-
9
7
  ## Installation
10
8
 
11
9
  Add to your application's Gemfile:
12
10
 
13
11
  ```ruby
14
12
  group :test do
15
- gem "angry_io", require: "angry_io/enable_for_ci_true"
13
+ gem "angry_io"
16
14
  end
17
15
  ```
18
16
 
@@ -24,19 +22,28 @@ gem install angry_io
24
22
 
25
23
  ## Usage
26
24
 
27
- The simplest setup is to point the Gemfile `require:` at `angry_io/enable_for_ci_true`. That file turns AngryIo on only when the `CI` environment variable is `"true"` — a convention set by GitHub Actions, GitLab CI, CircleCI, Travis, and others — and wires up whichever test framework is loaded (RSpec or Minitest); the other is a no-op.
25
+ Depending on your test framework, you should require either `angry_io/rspec` or `angry_io/minitest`:
28
26
 
29
27
  ```ruby
30
- # Gemfile
31
- gem "angry_io", require: "angry_io/enable_for_ci_true"
28
+ # spec_helper.rb (RSpec) or test_helper.rb (Minitest)
29
+ require "angry_io/rspec" # or "angry_io/minitest"
32
30
  ```
33
31
 
34
- That's it. Under `CI=true`, every test that writes to `$stdout` or `$stderr` raises:
32
+ By default, AngryIo is always on, and every test that writes to `$stdout` or `$stderr` now raises:
35
33
 
36
34
  ```
37
35
  IOError: not opened for writing
38
36
  ```
39
37
 
38
+ If you want to allow test output in some environments but not in others - e.g allow output when testing locally, but fail on CI - you can configure like this:
39
+
40
+ ```ruby
41
+ # On by default; turn it off in environments where you'll allow real output.
42
+ AngryIo.configure do |config|
43
+ config.enabled = -> { ENV["CI"] == "true" }
44
+ end
45
+ ```
46
+
40
47
  ### Opting out
41
48
 
42
49
  While onboarding this gem, some tests will likely already be writing to stdout. Opt them out per-test until they are fixed:
@@ -59,22 +66,6 @@ class PrintTest < Minitest::Test
59
66
  end
60
67
  ```
61
68
 
62
- ### Manual setup
63
-
64
- If you'd rather control the gate yourself, require an adapter directly. `enabled` defaults to always-on, so it's most useful as a kill switch for environments where you need real output:
65
-
66
- ```ruby
67
- # spec_helper.rb (RSpec) or test_helper.rb (Minitest)
68
- require "angry_io/rspec" # or "angry_io/minitest"
69
-
70
- # On by default; turn it off in environments where you need real output.
71
- AngryIo.configure do |config|
72
- config.enabled = -> { ENV["ANGRY_IO"] != "off" }
73
- end
74
- ```
75
-
76
- Requiring `angry_io/rspec` or `angry_io/minitest` self-registers the hook if that framework is loaded; requiring plain `angry_io` gives you just the `AngryIo::Stream` class with no side effects.
77
-
78
69
  ## Configuration
79
70
 
80
71
  `AngryIo.configure` yields a config struct with two fields:
@@ -82,7 +73,6 @@ Requiring `angry_io/rspec` or `angry_io/minitest` self-registers the hook if tha
82
73
  | Field | Default | Description |
83
74
  | --- | --- | --- |
84
75
  | `enabled` | `-> { true }` | A callable returning whether AngryIo is active. Invoked once per test, so it can read env vars or feature flags live. |
85
- | `opt_out_metadata` | `:i_absolutely_need_to_write_to_stdout` | The RSpec metadata symbol that opts an example out. |
86
76
 
87
77
  ## How it works
88
78
 
@@ -4,10 +4,8 @@ require "angry_io"
4
4
 
5
5
  # Prepends an override of +Minitest::Test#run+ that swaps $stdout/$stderr to
6
6
  # AngryIo::Stream instances around each test. A test class opts out by calling
7
- # +i_absolutely_need_to_write_to_stdout!+ in its body a nod to minitest's own
8
- # +i_suck_and_my_tests_are_order_dependent!+. Force-loads Minitest so
9
- # registration works regardless of Bundler.require ordering; no-op if Minitest
10
- # isn't installed.
7
+ # +i_absolutely_need_to_write_to_stdout!+ in its body. Force-loads Minitest so
8
+ # registration works regardless of Bundler.require ordering.
11
9
  module AngryIo
12
10
  module Minitest
13
11
  module Adapter
@@ -34,9 +32,5 @@ module AngryIo
34
32
  end
35
33
  end
36
34
 
37
- begin
38
- require "minitest"
39
- AngryIo::Minitest.setup!
40
- rescue LoadError
41
- # Minitest isn't installed; nothing to wire up.
42
- end
35
+ require "minitest"
36
+ AngryIo::Minitest.setup!
@@ -3,17 +3,16 @@
3
3
  require "angry_io"
4
4
 
5
5
  # Registers an +around+ hook that swaps $stdout/$stderr to AngryIo::Stream
6
- # instances during each example, unless the example opts out via the configured
7
- # metadata (default +:i_absolutely_need_to_write_to_stdout+). Force-loads
8
- # rspec-core so registration works regardless of Bundler.require ordering;
9
- # no-op if RSpec isn't installed.
6
+ # instances during each example, unless the example opts out via the
7
+ # +:i_absolutely_need_to_write_to_stdout+ metadata. Force-loads rspec-core so
8
+ # registration works regardless of Bundler.require ordering.
10
9
  module AngryIo
11
10
  module RSpec
12
11
  def self.setup!
13
12
  ::RSpec.configure do |config|
14
13
  config.around do |example|
15
- opt_out = example.metadata.key?(AngryIo.config.opt_out_metadata) &&
16
- example.metadata[AngryIo.config.opt_out_metadata]
14
+ opt_out = example.metadata.key?(:i_absolutely_need_to_write_to_stdout) &&
15
+ example.metadata[:i_absolutely_need_to_write_to_stdout]
17
16
  AngryIo.around_streams(opted_out: opt_out) { example.run }
18
17
  end
19
18
  end
@@ -21,9 +20,5 @@ module AngryIo
21
20
  end
22
21
  end
23
22
 
24
- begin
25
- require "rspec/core"
26
- AngryIo::RSpec.setup!
27
- rescue LoadError
28
- # RSpec isn't installed; nothing to wire up.
29
- end
23
+ require "rspec/core"
24
+ AngryIo::RSpec.setup!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AngryIo
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/angry_io.rb CHANGED
@@ -13,10 +13,9 @@ module AngryIo
13
13
  end
14
14
  end
15
15
 
16
- Config = Struct.new(:enabled, :opt_out_metadata) do
16
+ Config = Struct.new(:enabled) do
17
17
  def initialize
18
18
  self.enabled = -> { true }
19
- self.opt_out_metadata = :i_absolutely_need_to_write_to_stdout
20
19
  end
21
20
  end
22
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angry_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Quorning
@@ -23,7 +23,6 @@ files:
23
23
  - LICENSE.txt
24
24
  - README.md
25
25
  - lib/angry_io.rb
26
- - lib/angry_io/enable_for_ci_true.rb
27
26
  - lib/angry_io/minitest.rb
28
27
  - lib/angry_io/rspec.rb
29
28
  - lib/angry_io/version.rb
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Require this file from your Gemfile (+require: "angry_io/enable_for_ci_true"+)
4
- # to turn AngryIo on only when the +CI+ environment variable is +"true"+ — a
5
- # convention set by GitHub Actions, GitLab CI, CircleCI, Travis, and others.
6
- # Whichever test framework is loaded (RSpec or Minitest) wires itself up; the
7
- # other is a no-op.
8
-
9
- require "angry_io"
10
-
11
- AngryIo.configure do |config|
12
- config.enabled = -> { ENV["CI"] == "true" }
13
- end
14
-
15
- require "angry_io/rspec"
16
- require "angry_io/minitest"