rspec-capturing-formatter 1.0.2 → 1.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 +4 -4
- data/README.md +2 -2
- data/Rakefile +2 -1
- data/lib/rspec/capturing_formatter/renderer.rb +21 -7
- data/lib/rspec/capturing_formatter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86c5a7a4ac477c385790c51f48ec8a541a2ddb98dd7ae54221eabab56cb1cd8d
|
|
4
|
+
data.tar.gz: 4f2dfe985f9cc9fa07e9657c91d2237f8aa4785444636302047845c53a16fa1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65b49e1b9f9412f070c336a9e0af3678b6b56f297919b076ce2d84216b589ba5b5b556763972cbe4869141d4b69cdc26ae91d7d0a0d84017a8c62e3c3ec5044a
|
|
7
|
+
data.tar.gz: fe4ffca9eb311c1502d51ca61ccc9525361839ad73c11e55564bd5946814391ae329eb755cc2aebbbf64d51be5922da04154ccd42086a6b37104ba7c5c4c56b4
|
data/README.md
CHANGED
|
@@ -98,9 +98,9 @@ RSpec::CapturingFormatter.configure do |config|
|
|
|
98
98
|
end
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
When `config.color == true`, coloring is enabled
|
|
101
|
+
When `config.color == true`, coloring is enabled for TTY destinations and disabled for redirected output by default. `FORCE_COLOR` enables coloring when it is non-empty and not `0`; RSpec's `--force-color` has the same effect. Coloring is always disabled when `NO_COLOR`, `config.color = false`, or RSpec's `--no-color` option is set.
|
|
102
102
|
|
|
103
|
-
On Windows, interactive coloring is supported in Windows Terminal. Legacy Windows console sessions are not supported color targets and receive plain-text output instead of raw ANSI escape sequences. Redirected reports
|
|
103
|
+
On Windows, interactive coloring is supported in Windows Terminal. Legacy Windows console sessions are not supported color targets and receive plain-text output instead of raw ANSI escape sequences. Redirected reports are plain by default and remain colored when `FORCE_COLOR` or `--force-color` is used.
|
|
104
104
|
|
|
105
105
|
## Output capture limitations
|
|
106
106
|
|
data/Rakefile
CHANGED
|
@@ -12,7 +12,8 @@ task :spec do
|
|
|
12
12
|
rspec_args << "--format"
|
|
13
13
|
rspec_args << "RSpec::CapturingFormatter"
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
force_color = ENV["FORCE_COLOR"]
|
|
16
|
+
if force_color && !force_color.empty? && force_color != "0"
|
|
16
17
|
rspec_args << "--force-color"
|
|
17
18
|
end
|
|
18
19
|
if (file = ENV["FILE"])
|
|
@@ -29,10 +29,11 @@ module RSpec
|
|
|
29
29
|
|
|
30
30
|
attr_reader :output
|
|
31
31
|
|
|
32
|
-
def initialize(output, configuration, capture_manager: nil, ansi_supported: nil)
|
|
32
|
+
def initialize(output, configuration, capture_manager: nil, ansi_supported: nil, env: ENV)
|
|
33
33
|
@output = output || StringIO.new
|
|
34
34
|
@configuration = configuration
|
|
35
35
|
@capture_manager = capture_manager
|
|
36
|
+
@env = env
|
|
36
37
|
@ansi_supported = ansi_supported.nil? ? WindowsTerminal.ansi_supported?(@output) : ansi_supported
|
|
37
38
|
@entry_started = false
|
|
38
39
|
@entry_kind = nil
|
|
@@ -223,7 +224,7 @@ module RSpec
|
|
|
223
224
|
private
|
|
224
225
|
|
|
225
226
|
def emit_captured_text(source, text, nonblocking: false)
|
|
226
|
-
text = strip_sgr(text) unless
|
|
227
|
+
text = strip_sgr(text) unless color_enabled?
|
|
227
228
|
return if text.empty?
|
|
228
229
|
|
|
229
230
|
# Once application SGR appears, formatter source color stays off until the capture boundary.
|
|
@@ -267,7 +268,7 @@ module RSpec
|
|
|
267
268
|
|
|
268
269
|
def line(value, color = nil)
|
|
269
270
|
value = value.to_s
|
|
270
|
-
value = strip_sgr(value) unless
|
|
271
|
+
value = strip_sgr(value) unless color_enabled?
|
|
271
272
|
write_raw(RESET) if color_enabled?
|
|
272
273
|
write_raw(style(value, color))
|
|
273
274
|
write_raw("\n")
|
|
@@ -363,11 +364,24 @@ module RSpec
|
|
|
363
364
|
|
|
364
365
|
def color_enabled?
|
|
365
366
|
return false unless @ansi_supported
|
|
366
|
-
return false
|
|
367
|
-
return false if
|
|
368
|
-
RSpec.configuration.respond_to?(:color_mode) && RSpec.configuration.color_mode == :off
|
|
367
|
+
return false unless @configuration.color
|
|
368
|
+
return false if @env["NO_COLOR"] && !@env["NO_COLOR"].empty?
|
|
369
369
|
|
|
370
|
-
|
|
370
|
+
color_mode = rspec_color_mode
|
|
371
|
+
return false if color_mode == :off
|
|
372
|
+
return true if color_mode == :on
|
|
373
|
+
|
|
374
|
+
force_color = @env["FORCE_COLOR"]
|
|
375
|
+
return true if force_color && !force_color.empty? && force_color != "0"
|
|
376
|
+
|
|
377
|
+
@output.respond_to?(:tty?) && @output.tty?
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
def rspec_color_mode
|
|
381
|
+
return unless defined?(RSpec) && RSpec.respond_to?(:configuration)
|
|
382
|
+
|
|
383
|
+
configuration = RSpec.configuration
|
|
384
|
+
configuration.color_mode if configuration.respond_to?(:color_mode)
|
|
371
385
|
end
|
|
372
386
|
|
|
373
387
|
def style(value, color)
|