no_shit_in_my_green_dots 0.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 +7 -0
- data/.github/workflows/ci.yml +28 -0
- data/.mise.toml +2 -0
- data/.standard.yml +1 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/RELEASE.md +10 -0
- data/Rakefile +17 -0
- data/gemspec_helper.rb +43 -0
- data/lib/no_shit_in_my_green_dots/minitest.rb +43 -0
- data/lib/no_shit_in_my_green_dots/rspec.rb +34 -0
- data/lib/no_shit_in_my_green_dots/version.rb +5 -0
- data/lib/no_shit_in_my_green_dots.rb +65 -0
- data/no_stuff_in_my_green_dots.gemspec +8 -0
- data/sig/no_shit_in_my_green_dots.rbs +7 -0
- data/test/fixtures/minitest/noisy/noisy_suite.rb +12 -0
- data/test/fixtures/minitest/noisy/test_helper.rb +8 -0
- data/test/fixtures/minitest/quiet/quiet_suite.rb +13 -0
- data/test/fixtures/minitest/quiet/test_helper.rb +8 -0
- data/test/fixtures/rspec/noisy/spec_helper.rb +14 -0
- data/test/fixtures/rspec/noisy/stdout_spec.rb +14 -0
- data/test/fixtures/rspec/quiet/spec_helper.rb +14 -0
- data/test/fixtures/rspec/quiet/stdout_spec.rb +9 -0
- data/test/minitest_integration_test.rb +44 -0
- data/test/rspec_integration_test.rb +45 -0
- data/test/test_helper.rb +6 -0
- metadata +125 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 60d92b885844546d8b21b5a5c65a7ee3ba5f3dcbc7a0babdf6f8e9b8cac191bd
|
|
4
|
+
data.tar.gz: 71f19dd05cb35ffb9768ff103205aedeb9756a713befcb0cc79da1a4609deef7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a6775155b5cdc02c3754a3c2efef143d7eb3bc58173f44c66b18a583551e1bcdac08086954093c57c68abf629c6fb92a080ccaf8de5a5ea1e4b61a65b67fb4f2
|
|
7
|
+
data.tar.gz: 8cbf9bac58a4f359cc3b6d572ef830df0ecbf4b28c82343a0071ce2c80eb6aef6af148a9181301f4dcfa1f2aefa75d241a1b7d227d256119049b4696df3619d8
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
ruby: ["3.2", "3.3", "3.4"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Ruby
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
|
|
27
|
+
- name: Run standardrb + tests
|
|
28
|
+
run: bundle exec rake
|
data/.mise.toml
ADDED
data/.standard.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby_version: 3.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nate Berkopec
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# NoShitInMyGreenDots
|
|
2
|
+
|
|
3
|
+
Are you sick of this?
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
Run options: --seed 12345
|
|
7
|
+
|
|
8
|
+
# Running:
|
|
9
|
+
|
|
10
|
+
.D, [2025-01-20T10:23:45.123456 #12345] DEBUG -- : Redis connected to localhost:6379
|
|
11
|
+
.I, [2025-01-20T10:23:45.234567 #12345] INFO -- : Processing user #1234
|
|
12
|
+
.[ActiveJob] Enqueued EmailJob (Job ID: abc-123) to Sidekiq(default)
|
|
13
|
+
.HTTP Request: GET /api/users
|
|
14
|
+
..D, [2025-01-20T10:23:45.345678 #12345] DEBUG -- : Cache miss for key: user_1234
|
|
15
|
+
.[Rack::Handler::WEBrick] 127.0.0.1 - - [20/Jan/2025:10:23:45 EST] "GET /health HTTP/1.1" 200
|
|
16
|
+
I, [2025-01-20T10:23:45.456789 #12345] INFO -- : Background job completed in 0.05s
|
|
17
|
+
..
|
|
18
|
+
|
|
19
|
+
Finished in 0.012345s, 810.0 runs/s, 810.0 assertions/s.
|
|
20
|
+
|
|
21
|
+
10 runs, 10 assertions, 0 failures, 0 errors, 0 skips
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Now, you can enforce your overly fastidious notions of clean test output on your friends and co-workers!
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
Run options: --seed 12345
|
|
28
|
+
|
|
29
|
+
# Running:
|
|
30
|
+
|
|
31
|
+
....F.....
|
|
32
|
+
|
|
33
|
+
Finished in 0.012345s, 810.0 runs/s, 810.0 assertions/s.
|
|
34
|
+
|
|
35
|
+
1) STDOUT:
|
|
36
|
+
NoisyTest#test_logs [test/noisy_test.rb:6]:
|
|
37
|
+
Test wrote to STDOUT:
|
|
38
|
+
---
|
|
39
|
+
direct write
|
|
40
|
+
I, [2025-01-01T12:34:56.789012 #1234] INFO -- : logger write
|
|
41
|
+
child_output
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
10 runs, 10 assertions, 1 failures, 0 errors, 0 skips
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
Add the gem to your bundle:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
group :test do
|
|
53
|
+
gem "no_shit_in_my_green_dots"
|
|
54
|
+
end
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
If you need a work-safe name, use:
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
group :test do
|
|
61
|
+
gem "no_stuff_in_my_green_dots"
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## How it works
|
|
66
|
+
|
|
67
|
+
For each example/test, STDOUT is redirected to a pipe. If anything other than the test framework's reporter writes to STDOUT during that example/test, the example/test fails with a short dump of the captured output (truncated for very noisy cases). Only suite-wide enablement is supported; per-example toggles are intentionally not provided. STDERR is left alone, and IO objects that were duped from STDOUT *before* enabling the gem may not be caught—point long-lived loggers at `STDOUT`/`$stdout` after enabling if you need them guarded.
|
data/RELEASE.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Release process
|
|
2
|
+
|
|
3
|
+
1. Bump `lib/no_shit_in_my_green_dots/version.rb`.
|
|
4
|
+
2. Release the primary gem (keeps tagging/metadata as-is):
|
|
5
|
+
- `bundle exec rake release`
|
|
6
|
+
3. Publish the work-safe name at the same version (no extra tag):
|
|
7
|
+
- `bundle exec gem build no_stuff_in_my_green_dots.gemspec`
|
|
8
|
+
- `bundle exec gem push no_stuff_in_my_green_dots-<VERSION>.gem`
|
|
9
|
+
|
|
10
|
+
Both gemspecs rely on the same code and version constant; keep them in lockstep.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_helper"
|
|
4
|
+
Bundler::GemHelper.install_tasks name: "no_shit_in_my_green_dots"
|
|
5
|
+
require "rake/testtask"
|
|
6
|
+
|
|
7
|
+
desc "Run standardrb (lint)"
|
|
8
|
+
task :standard do
|
|
9
|
+
sh "bundle exec standardrb"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Rake::TestTask.new(:test) do |t|
|
|
13
|
+
t.libs << "test"
|
|
14
|
+
t.pattern = "test/**/*_test.rb"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
task default: %i[standard test]
|
data/gemspec_helper.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/no_shit_in_my_green_dots/version"
|
|
4
|
+
|
|
5
|
+
module NoShitInMyGreenDots
|
|
6
|
+
module GemspecHelper
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def build(name:, gemspec_filename:)
|
|
10
|
+
Gem::Specification.new do |spec|
|
|
11
|
+
spec.name = name
|
|
12
|
+
spec.version = NoShitInMyGreenDots::VERSION
|
|
13
|
+
spec.authors = ["Nate Berkopec"]
|
|
14
|
+
spec.email = ["nate.berkopec@gmail.com"]
|
|
15
|
+
|
|
16
|
+
spec.summary = "Fails tests that leak STDOUT into your green dots."
|
|
17
|
+
spec.description = "A small helper you drop into spec_helper.rb or test_helper.rb to fail examples that write to STDOUT."
|
|
18
|
+
spec.homepage = "https://github.com/nateberkopec/no_shit_in_my_green_dots"
|
|
19
|
+
spec.license = "MIT"
|
|
20
|
+
spec.required_ruby_version = ">= 3.1.0"
|
|
21
|
+
|
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/nateberkopec/no_shit_in_my_green_dots"
|
|
24
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
25
|
+
|
|
26
|
+
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
|
|
27
|
+
ls.readlines("\x0", chomp: true).reject do |f|
|
|
28
|
+
(f == gemspec_filename) ||
|
|
29
|
+
f.start_with?(*%w[bin/ Gemfile .gitignore])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
spec.bindir = "exe"
|
|
33
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
34
|
+
spec.require_paths = ["lib"]
|
|
35
|
+
|
|
36
|
+
spec.add_development_dependency "minitest", "~> 5.21"
|
|
37
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
38
|
+
spec.add_development_dependency "rspec", "~> 3.13"
|
|
39
|
+
spec.add_development_dependency "standard", "~> 1.40"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest"
|
|
4
|
+
|
|
5
|
+
module NoShitInMyGreenDots
|
|
6
|
+
module Integrations
|
|
7
|
+
module Minitest
|
|
8
|
+
class StdoutLeak < ::Minitest::Assertion
|
|
9
|
+
RESULT_LABEL = "STDOUT"
|
|
10
|
+
|
|
11
|
+
def initialize(output)
|
|
12
|
+
super(NoShitInMyGreenDots.leak_message(output))
|
|
13
|
+
set_backtrace(caller)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def result_label
|
|
17
|
+
RESULT_LABEL
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
module TestExtension
|
|
22
|
+
def run
|
|
23
|
+
result = nil
|
|
24
|
+
stdout, = capture_io { result = super }
|
|
25
|
+
|
|
26
|
+
unless stdout.nil? || stdout.empty?
|
|
27
|
+
result.failures << StdoutLeak.new(stdout)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
result
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.install!
|
|
35
|
+
return if @installed
|
|
36
|
+
|
|
37
|
+
require "minitest/test"
|
|
38
|
+
::Minitest::Test.prepend(TestExtension)
|
|
39
|
+
@installed = true
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rspec/core"
|
|
4
|
+
|
|
5
|
+
module NoShitInMyGreenDots
|
|
6
|
+
module Integrations
|
|
7
|
+
module RSpec
|
|
8
|
+
class StdoutLeak < StandardError
|
|
9
|
+
def initialize(output)
|
|
10
|
+
super(NoShitInMyGreenDots.leak_message(output))
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.install!
|
|
15
|
+
return if @installed
|
|
16
|
+
|
|
17
|
+
::RSpec.configure do |config|
|
|
18
|
+
config.around do |example|
|
|
19
|
+
matcher = ::RSpec::Matchers::BuiltIn::Output.new(nil).to_stdout_from_any_process
|
|
20
|
+
matcher.matches?(-> { example.run })
|
|
21
|
+
captured_output = matcher.instance_variable_get(:@actual).to_s
|
|
22
|
+
|
|
23
|
+
next if captured_output.nil? || captured_output.empty?
|
|
24
|
+
next if example.exception
|
|
25
|
+
|
|
26
|
+
raise StdoutLeak.new(captured_output)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
@installed = true
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "no_shit_in_my_green_dots/version"
|
|
4
|
+
|
|
5
|
+
module NoShitInMyGreenDots
|
|
6
|
+
class Error < StandardError; end
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def enable!(framework = nil)
|
|
10
|
+
@enabled ||= {}
|
|
11
|
+
|
|
12
|
+
frameworks = framework ? [framework] : [:rspec, :minitest]
|
|
13
|
+
frameworks.each { |fw| install_framework(fw) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def enabled?(framework = nil)
|
|
17
|
+
return false unless defined?(@enabled)
|
|
18
|
+
return @enabled.values.any? if framework.nil?
|
|
19
|
+
|
|
20
|
+
!!@enabled[framework]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def leak_message(output)
|
|
24
|
+
return "Test wrote to STDOUT (no content captured)." if output.nil? || output.empty?
|
|
25
|
+
|
|
26
|
+
trimmed = output.dup
|
|
27
|
+
trimmed = trimmed[0, 720] + "...(truncated)" if trimmed.length > 720
|
|
28
|
+
<<~MSG
|
|
29
|
+
Test wrote to STDOUT:
|
|
30
|
+
---
|
|
31
|
+
#{trimmed}
|
|
32
|
+
---
|
|
33
|
+
MSG
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def install_framework(framework)
|
|
39
|
+
return if @enabled[framework]
|
|
40
|
+
|
|
41
|
+
case framework
|
|
42
|
+
when :rspec
|
|
43
|
+
require "rspec/core"
|
|
44
|
+
require_relative "no_shit_in_my_green_dots/rspec"
|
|
45
|
+
Integrations::RSpec.install!
|
|
46
|
+
when :minitest
|
|
47
|
+
require "minitest"
|
|
48
|
+
require_relative "no_shit_in_my_green_dots/minitest"
|
|
49
|
+
Integrations::Minitest.install!
|
|
50
|
+
else
|
|
51
|
+
raise Error, "Unknown framework #{framework.inspect}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
@enabled[framework] = true
|
|
55
|
+
rescue LoadError
|
|
56
|
+
# Framework not available; skip install
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def auto_enable!
|
|
60
|
+
enable!
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
NoShitInMyGreenDots.send(:auto_enable!)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../../../../../lib", __dir__))
|
|
4
|
+
|
|
5
|
+
require "rspec"
|
|
6
|
+
require "no_shit_in_my_green_dots"
|
|
7
|
+
|
|
8
|
+
NoShitInMyGreenDots.enable!(:rspec)
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
config.expect_with :rspec do |c|
|
|
12
|
+
c.syntax = :expect
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe "stdout noise" do
|
|
6
|
+
it "fails when writing to stdout" do
|
|
7
|
+
puts "spec noise"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "fails when child writes to stdout" do
|
|
11
|
+
pid = fork { $stdout.puts "spec_child" }
|
|
12
|
+
Process.wait(pid)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../../../../../lib", __dir__))
|
|
4
|
+
|
|
5
|
+
require "rspec"
|
|
6
|
+
require "no_shit_in_my_green_dots"
|
|
7
|
+
|
|
8
|
+
NoShitInMyGreenDots.enable!(:rspec)
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
config.expect_with :rspec do |c|
|
|
12
|
+
c.syntax = :expect
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
require "open3"
|
|
5
|
+
|
|
6
|
+
class MinitestIntegrationTest < Minitest::Test
|
|
7
|
+
def test_suite_fails_when_stdout_is_used
|
|
8
|
+
status, output = run_minitest_suite(fixture: "noisy")
|
|
9
|
+
|
|
10
|
+
refute status.success?, "Expected minitest suite to fail when STDOUT is used"
|
|
11
|
+
assert_includes output, "Test wrote to STDOUT"
|
|
12
|
+
assert_includes output, "direct write"
|
|
13
|
+
assert_includes output, "logger write"
|
|
14
|
+
assert_includes output, "child_output"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_suite_passes_when_quiet
|
|
18
|
+
status, output = run_minitest_suite(fixture: "quiet")
|
|
19
|
+
|
|
20
|
+
assert status.success?, "Expected quiet minitest suite to pass"
|
|
21
|
+
refute_includes output, "Test wrote to STDOUT"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def run_minitest_suite(fixture:)
|
|
27
|
+
fixture_path = File.expand_path("fixtures/minitest/#{fixture}", __dir__)
|
|
28
|
+
filename = "#{fixture}_suite.rb"
|
|
29
|
+
stdout, stderr, status = Open3.capture3(
|
|
30
|
+
bundle_env,
|
|
31
|
+
"bundle",
|
|
32
|
+
"exec",
|
|
33
|
+
"ruby",
|
|
34
|
+
filename,
|
|
35
|
+
chdir: fixture_path
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
[status, stdout + stderr]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def bundle_env
|
|
42
|
+
{"BUNDLE_GEMFILE" => File.expand_path("../Gemfile", __dir__)}
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
require "open3"
|
|
5
|
+
|
|
6
|
+
class RSpecIntegrationTest < Minitest::Test
|
|
7
|
+
def test_suite_fails_when_stdout_is_used
|
|
8
|
+
status, output = run_rspec_suite(fixture: "noisy")
|
|
9
|
+
|
|
10
|
+
refute status.success?, "Expected rspec suite to fail when STDOUT is used"
|
|
11
|
+
assert_includes output, "Test wrote to STDOUT"
|
|
12
|
+
assert_includes output, "spec noise"
|
|
13
|
+
assert_includes output, "spec_child"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_suite_passes_when_quiet
|
|
17
|
+
status, output = run_rspec_suite(fixture: "quiet")
|
|
18
|
+
|
|
19
|
+
assert status.success?, "Expected quiet rspec suite to pass"
|
|
20
|
+
refute_includes output, "Test wrote to STDOUT"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def run_rspec_suite(fixture:)
|
|
26
|
+
fixture_path = File.expand_path("fixtures/rspec/#{fixture}", __dir__)
|
|
27
|
+
|
|
28
|
+
stdout, stderr, status = Open3.capture3(
|
|
29
|
+
bundle_env,
|
|
30
|
+
"bundle",
|
|
31
|
+
"exec",
|
|
32
|
+
"rspec",
|
|
33
|
+
"--format",
|
|
34
|
+
"progress",
|
|
35
|
+
"stdout_spec.rb",
|
|
36
|
+
chdir: fixture_path
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
[status, stdout + stderr]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def bundle_env
|
|
43
|
+
{"BUNDLE_GEMFILE" => File.expand_path("../Gemfile", __dir__)}
|
|
44
|
+
end
|
|
45
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: no_shit_in_my_green_dots
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nate Berkopec
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: minitest
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '5.21'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '5.21'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rake
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '13.0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '13.0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rspec
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '3.13'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '3.13'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: standard
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '1.40'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '1.40'
|
|
68
|
+
description: A small helper you drop into spec_helper.rb or test_helper.rb to fail
|
|
69
|
+
examples that write to STDOUT.
|
|
70
|
+
email:
|
|
71
|
+
- nate.berkopec@gmail.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- ".github/workflows/ci.yml"
|
|
77
|
+
- ".mise.toml"
|
|
78
|
+
- ".standard.yml"
|
|
79
|
+
- LICENSE.txt
|
|
80
|
+
- README.md
|
|
81
|
+
- RELEASE.md
|
|
82
|
+
- Rakefile
|
|
83
|
+
- gemspec_helper.rb
|
|
84
|
+
- lib/no_shit_in_my_green_dots.rb
|
|
85
|
+
- lib/no_shit_in_my_green_dots/minitest.rb
|
|
86
|
+
- lib/no_shit_in_my_green_dots/rspec.rb
|
|
87
|
+
- lib/no_shit_in_my_green_dots/version.rb
|
|
88
|
+
- no_stuff_in_my_green_dots.gemspec
|
|
89
|
+
- sig/no_shit_in_my_green_dots.rbs
|
|
90
|
+
- test/fixtures/minitest/noisy/noisy_suite.rb
|
|
91
|
+
- test/fixtures/minitest/noisy/test_helper.rb
|
|
92
|
+
- test/fixtures/minitest/quiet/quiet_suite.rb
|
|
93
|
+
- test/fixtures/minitest/quiet/test_helper.rb
|
|
94
|
+
- test/fixtures/rspec/noisy/spec_helper.rb
|
|
95
|
+
- test/fixtures/rspec/noisy/stdout_spec.rb
|
|
96
|
+
- test/fixtures/rspec/quiet/spec_helper.rb
|
|
97
|
+
- test/fixtures/rspec/quiet/stdout_spec.rb
|
|
98
|
+
- test/minitest_integration_test.rb
|
|
99
|
+
- test/rspec_integration_test.rb
|
|
100
|
+
- test/test_helper.rb
|
|
101
|
+
homepage: https://github.com/nateberkopec/no_shit_in_my_green_dots
|
|
102
|
+
licenses:
|
|
103
|
+
- MIT
|
|
104
|
+
metadata:
|
|
105
|
+
homepage_uri: https://github.com/nateberkopec/no_shit_in_my_green_dots
|
|
106
|
+
source_code_uri: https://github.com/nateberkopec/no_shit_in_my_green_dots
|
|
107
|
+
rubygems_mfa_required: 'true'
|
|
108
|
+
rdoc_options: []
|
|
109
|
+
require_paths:
|
|
110
|
+
- lib
|
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: 3.1.0
|
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
requirements: []
|
|
122
|
+
rubygems_version: 3.6.9
|
|
123
|
+
specification_version: 4
|
|
124
|
+
summary: Fails tests that leak STDOUT into your green dots.
|
|
125
|
+
test_files: []
|