sus-fixtures-console 0.4.0 → 0.4.1

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: 1e7cec179de60237b4aa5c02af965c5c408922527355fdc2a3ff4bb461af02c5
4
+ data.tar.gz: b0b6299b341defd1e00675e08188434456a6f06f63aa9fef38a879d867439e2a
5
5
  SHA512:
6
- metadata.gz: 3907c7561299fad43950dcfbb1cbd53cb6add6648f3ca79d92b33079e011d2c3a4c917beb4da698fa7c1bb95bdb3f1c14c539abd76f185056be4cd89eb6e1e52
7
- data.tar.gz: a02d2e1fdd9c1735429afee13b7be05d4014cd37c01354024db87c2f1ec2698d90f1d6f70df61b9fd89794b95daa9f6d20e98dedabd7df7e0f0594dcd48100bf
6
+ metadata.gz: e435cfb4bce7c62d9c94bbe46d74a347665870fd1ced6c5e8a52c6b072b85b8b67c9d81e67383ad0ec3c0ec04c8ea0214c25f78003c7c652b1c1d5863676d27b
7
+ data.tar.gz: c935ce69e39432c734c91de3fe09369b4475cc4ee7732db7af435148815bca90cacc6f613b40043fe5dc3eac5b92978cdaf2ed577e95447aab3d9b91a7c3a86b
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_context 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_context 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_context 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.
@@ -6,7 +6,7 @@
6
6
  module Sus
7
7
  module Fixtures
8
8
  module Console
9
- VERSION = "0.4.0"
9
+ VERSION = "0.4.1"
10
10
  end
11
11
  end
12
12
  end
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.4.1
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
metadata.gz.sig CHANGED
Binary file