Skip to content

Commit 20383d6

Browse files
committed
Do not output running spring status for commands with prefix 'spring'
1 parent 347731e commit 20383d6

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

bin/spring

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ end
4646
lib = File.expand_path("../../lib", __FILE__)
4747
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) # enable local development
4848
require 'spring/client'
49+
# if the user knows that spring is called, do not show running spring
50+
Spring.quiet = true if $0.include? 'spring'
4951
Spring::Client.run(ARGV)

lib/spring/test/acceptance_test.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ def assert_failure(command, expected_output = nil)
4747
assert_output artifacts, expected_output if expected_output
4848
end
4949

50+
def refute_output_includes(command, not_expected)
51+
artifacts = app.run(*Array(command))
52+
not_expected.each do |stream, output|
53+
assert !artifacts[stream].include?(output),
54+
"expected #{stream} to not include '#{output}'.\n\n#{app.debug(artifacts)}"
55+
end
56+
end
57+
5058
def assert_speedup(ratio = DEFAULT_SPEEDUP)
5159
if ENV['CI']
5260
yield
@@ -99,12 +107,15 @@ def without_gem(name)
99107
assert_success app.spring_test_command, stdout: "Running via Spring preloader in process"
100108
end
101109

110+
test "does not tell the user that spring is being used when the user used spring manually" do
111+
refute_output_includes "spring rails runner ''", stdout: "Running via Spring preloader in process"
112+
refute_output_includes "spring rake test", stdout: "Running via Spring preloader in process"
113+
end
114+
102115
test "does not tell the user that spring is being used when used automatically via binstubs but quiet is enabled" do
103116
File.write("#{app.user_home}/.spring.rb", "Spring.quiet = true")
104117
assert_success "bin/rails runner ''"
105-
artifacts = app.run("bin/rails runner ''")
106-
assert !artifacts[:stdout].include?("Running via Spring preloader in process"),
107-
"expected stdout to not include 'Running via Spring preloader in process'.\n\n#{app.debug(artifacts)}"
118+
refute_output_includes "bin/rails runner ''", stdout: 'Running via Spring preloader in process'
108119
end
109120

110121
test "test changes are picked up" do

0 commit comments

Comments
 (0)