sus-fixtures-console 0.4.0 → 0.5.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: 866c9717a17e7c6a2bb6a9e5c0100c5f2f3873987c1c61aaab238c3753790e0e
4
- data.tar.gz: 3ec4c6a398935168f9666b192661e9223069ba501d02cd65514e9d80773fba83
3
+ metadata.gz: f7422fc0acabbaaab2d3cf9f23b802989e50c3a8aeadc4889270288c7fe4b6bc
4
+ data.tar.gz: 320c04a418a41a2f536d8a3b4919439b45e06a3b1b709966c03663c9cbf8b992
5
5
  SHA512:
6
- metadata.gz: 3907c7561299fad43950dcfbb1cbd53cb6add6648f3ca79d92b33079e011d2c3a4c917beb4da698fa7c1bb95bdb3f1c14c539abd76f185056be4cd89eb6e1e52
7
- data.tar.gz: a02d2e1fdd9c1735429afee13b7be05d4014cd37c01354024db87c2f1ec2698d90f1d6f70df61b9fd89794b95daa9f6d20e98dedabd7df7e0f0594dcd48100bf
6
+ metadata.gz: aefade50186e2ed0af3e6c3d0c81a270bb4645b63aaa999c650fe4c4113418c867ac513273d487293c4810f7624af30facfc0b6e6bba5ff385dd8579b975d52e
7
+ data.tar.gz: 72883f4c29cbd9e34df52befc688c68a51f55a73994568a378062c9f4f50a87d930e72288f4ef4d67830382d4e0c1099c9b17fc89d22fd92124270fd78b36eb8
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,87 @@
1
+ # Getting Started
2
+
3
+ This guide explains how to use the `Sus::Fixtures::Console` gem to redirect console logging output during tests.
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your project:
8
+
9
+ ``` bash
10
+ $ bundle add sus-fixtures-console
11
+ ```
12
+
13
+ ## Core Concepts
14
+
15
+ `sus-fixtures-console` provides two main fixtures:
16
+
17
+ - {ruby Sus::Fixtures::Console::CapturedLogger} - Captures console output for inspection and testing.
18
+ - {ruby Sus::Fixtures::Console::NullLogger} - Suppresses console output to reduce noise during test runs.
19
+
20
+ ## Usage
21
+
22
+ ### Capturing Console Output
23
+
24
+ Here is a basic example of a test, that captures the log output:
25
+
26
+ ``` ruby
27
+ require "sus/fixtures/console/captured_logger"
28
+
29
+ describe Sus::Fixtures::Console::CapturedLogger do
30
+ include Sus::Fixtures::Console::CapturedLogger
31
+
32
+ it "should capture output" do
33
+ Console.debug("Hello, World!")
34
+
35
+ expect(console_capture.last).to have_keys(
36
+ severity: be == :debug,
37
+ subject: be == "Hello, World!"
38
+ )
39
+ end
40
+ end
41
+ ```
42
+
43
+ ### Ignoring Console Output
44
+
45
+ If you want to ignore the console output, you can use the `Sus::Fixtures::Console::NullLogger` fixture:
46
+
47
+ ``` ruby
48
+ describe Sus::Fixtures::Console::NullLogger do
49
+ include Sus::Fixtures::Console::NullLogger
50
+
51
+ it "should capture output" do
52
+ expect($stderr).not.to receive(:puts)
53
+ expect($stderr).not.to receive(:write)
54
+
55
+ Console.debug("Hello, World!")
56
+ end
57
+ end
58
+ ```
59
+
60
+ ### Advanced Usage
61
+
62
+ You can also use the `expect_console` helper method for more fluent test assertions:
63
+
64
+ ``` ruby
65
+ describe Sus::Fixtures::Console::CapturedLogger do
66
+ include Sus::Fixtures::Console::CapturedLogger
67
+
68
+ it "can use expect_console helper" do
69
+ Console.info("Processing complete")
70
+
71
+ expect_console.to have_logged(
72
+ severity: be == :info,
73
+ subject: be == "Processing complete"
74
+ )
75
+ end
76
+ end
77
+ ```
78
+
79
+ ### Setting a Default Log Level
80
+
81
+ In many cases, you may wish to set a default log level that only prints warnings or above:
82
+
83
+ ``` ruby
84
+ # In your `config/sus.rb` file:
85
+ require "console"
86
+ Console.logger.warn!
87
+ ```
@@ -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 capturing Console output.
5
+ metadata:
6
+ documentation_uri: https://socketry.github.io/sus-fixtures-console/
7
+ funding_uri: https://github.com/sponsors/ioquatix/
8
+ source_code_uri: https://github.com/socketry/sus-fixtures-console.git
9
+ files:
10
+ - path: getting-started.md
11
+ title: Getting Started
12
+ description: This guide explains how to use the `Sus::Fixtures::Console` gem to
13
+ redirect console logging output during tests.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
6
  require "sus/shared"
7
7
  require "console"
@@ -13,11 +13,16 @@ module Sus
13
13
  module Console
14
14
  # Shared context for capturing console output during tests.
15
15
  # Provides access to captured log messages and helper methods for testing console logging.
16
- CapturedLogger = Sus::Shared("captured logger") do
17
- # @attribute [Console::Capture] Captures console output for inspection.
18
- let(:console_capture) {::Console::Capture.new}
19
- # @attribute [Console::Logger] Logger configured to capture output at DEBUG level.
20
- let(:console_logger) {::Console::Logger.new(console_capture, level: ::Console::Logger::DEBUG)}
16
+ module CapturedLogger
17
+ # @returns [Console::Capture] Captures console output for inspection.
18
+ def console_capture
19
+ @console_capture ||= ::Console::Capture.new
20
+ end
21
+
22
+ # @returns [Console::Logger] Logger configured to capture output at DEBUG level.
23
+ def console_logger
24
+ @console_logger ||= ::Console::Logger.new(console_capture, level: ::Console::Logger::DEBUG)
25
+ end
21
26
 
22
27
  # Set up console logger before test execution and clean up afterwards.
23
28
  def around
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
6
  require "sus/shared"
7
7
  require "console"
@@ -13,9 +13,11 @@ module Sus
13
13
  module Console
14
14
  # Shared context for suppressing console output during tests.
15
15
  # Redirects all console logging to a null output to prevent noise in test runs.
16
- NullLogger = Sus::Shared("null logger") do
17
- # @attribute [Console::Logger] Logger configured to suppress all output.
18
- let(:console_logger) {::Console::Logger.new(::Console::Output::Null.new)}
16
+ module NullLogger
17
+ # @returns [Console::Logger] Logger configured to suppress all output.
18
+ def console_logger
19
+ @console_logger ||= ::Console::Logger.new(::Console::Output::Null.new)
20
+ end
19
21
 
20
22
  # Set up null logger before test execution and clean up afterwards.
21
23
  def around
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
6
  module Sus
7
7
  module Fixtures
8
8
  module Console
9
- VERSION = "0.4.0"
9
+ VERSION = "0.5.0"
10
10
  end
11
11
  end
12
12
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "console/version"
7
7
  require_relative "console/captured_logger"
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2024, by Samuel Williams.
3
+ Copyright, 2024-2025, by Samuel Williams.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -20,6 +20,11 @@ Please see the [project documentation](https://socketry.github.io/sus-fixtures-c
20
20
 
21
21
  Please see the [project releases](https://socketry.github.io/sus-fixtures-console/releases/index) for all releases.
22
22
 
23
+ ### v0.5.0
24
+
25
+ - Prefer modules over `Sus::Shared` contexts for better integration.
26
+ - Use `include Sus::Fixtures::Console::NullLogger` instead of `include_context Sus::Fixtures::Console::NullLogger`.
27
+
23
28
  ### v0.4.0
24
29
 
25
30
  - Add agent context.
data/releases.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Releases
2
2
 
3
+ ## v0.5.0
4
+
5
+ - Prefer modules over `Sus::Shared` contexts for better integration.
6
+ - Use `include Sus::Fixtures::Console::NullLogger` instead of `include_context Sus::Fixtures::Console::NullLogger`.
7
+
3
8
  ## v0.4.0
4
9
 
5
10
  - Add agent context.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sus-fixtures-console
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -70,6 +70,8 @@ executables: []
70
70
  extensions: []
71
71
  extra_rdoc_files: []
72
72
  files:
73
+ - context/getting-started.md
74
+ - context/index.yaml
73
75
  - lib/sus/fixtures/console.rb
74
76
  - lib/sus/fixtures/console/captured_logger.rb
75
77
  - lib/sus/fixtures/console/null_logger.rb
@@ -98,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
100
  - !ruby/object:Gem::Version
99
101
  version: '0'
100
102
  requirements: []
101
- rubygems_version: 3.6.9
103
+ rubygems_version: 3.7.2
102
104
  specification_version: 4
103
105
  summary: Test fixtures for capturing Console output.
104
106
  test_files: []
metadata.gz.sig CHANGED
Binary file