sus-fixtures-console 0.4.1 → 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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/context/getting-started.md +5 -5
- data/lib/sus/fixtures/console/captured_logger.rb +11 -6
- data/lib/sus/fixtures/console/null_logger.rb +6 -4
- data/lib/sus/fixtures/console/version.rb +2 -2
- data/lib/sus/fixtures/console.rb +1 -1
- data/license.md +1 -1
- data/readme.md +5 -0
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7422fc0acabbaaab2d3cf9f23b802989e50c3a8aeadc4889270288c7fe4b6bc
|
4
|
+
data.tar.gz: 320c04a418a41a2f536d8a3b4919439b45e06a3b1b709966c03663c9cbf8b992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aefade50186e2ed0af3e6c3d0c81a270bb4645b63aaa999c650fe4c4113418c867ac513273d487293c4810f7624af30facfc0b6e6bba5ff385dd8579b975d52e
|
7
|
+
data.tar.gz: 72883f4c29cbd9e34df52befc688c68a51f55a73994568a378062c9f4f50a87d930e72288f4ef4d67830382d4e0c1099c9b17fc89d22fd92124270fd78b36eb8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/context/getting-started.md
CHANGED
@@ -24,10 +24,10 @@ $ bundle add sus-fixtures-console
|
|
24
24
|
Here is a basic example of a test, that captures the log output:
|
25
25
|
|
26
26
|
``` ruby
|
27
|
-
require
|
27
|
+
require "sus/fixtures/console/captured_logger"
|
28
28
|
|
29
29
|
describe Sus::Fixtures::Console::CapturedLogger do
|
30
|
-
|
30
|
+
include Sus::Fixtures::Console::CapturedLogger
|
31
31
|
|
32
32
|
it "should capture output" do
|
33
33
|
Console.debug("Hello, World!")
|
@@ -46,7 +46,7 @@ If you want to ignore the console output, you can use the `Sus::Fixtures::Consol
|
|
46
46
|
|
47
47
|
``` ruby
|
48
48
|
describe Sus::Fixtures::Console::NullLogger do
|
49
|
-
|
49
|
+
include Sus::Fixtures::Console::NullLogger
|
50
50
|
|
51
51
|
it "should capture output" do
|
52
52
|
expect($stderr).not.to receive(:puts)
|
@@ -63,7 +63,7 @@ You can also use the `expect_console` helper method for more fluent test asserti
|
|
63
63
|
|
64
64
|
``` ruby
|
65
65
|
describe Sus::Fixtures::Console::CapturedLogger do
|
66
|
-
|
66
|
+
include Sus::Fixtures::Console::CapturedLogger
|
67
67
|
|
68
68
|
it "can use expect_console helper" do
|
69
69
|
Console.info("Processing complete")
|
@@ -82,6 +82,6 @@ In many cases, you may wish to set a default log level that only prints warnings
|
|
82
82
|
|
83
83
|
``` ruby
|
84
84
|
# In your `config/sus.rb` file:
|
85
|
-
require
|
85
|
+
require "console"
|
86
86
|
Console.logger.warn!
|
87
87
|
```
|
@@ -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
|
17
|
-
# @
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
17
|
-
# @
|
18
|
-
|
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.
|
9
|
+
VERSION = "0.5.0"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/sus/fixtures/console.rb
CHANGED
data/license.md
CHANGED
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
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
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
103
|
+
rubygems_version: 3.7.2
|
104
104
|
specification_version: 4
|
105
105
|
summary: Test fixtures for capturing Console output.
|
106
106
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|