Skip to content

Commit

Permalink
Merge 80fd49c into 34df888
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanhefner committed Jun 23, 2020
2 parents 34df888 + 80fd49c commit f9906a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/thor/shell/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def ask(statement, *args)
# say("I know you knew that.")
#
def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
return if quiet?

buffer = prepare_message(message, *color)
buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")

Expand Down
15 changes: 15 additions & 0 deletions spec/shell/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ def shell
expect($stdout).to receive(:print).with("this_is_not_a_string\n")
shell.say(:this_is_not_a_string, nil, true)
end

it "does not print a message if muted" do
expect($stdout).not_to receive(:print)
shell.mute do
shell.say("Running...")
end
end

it "does not print a message if base is set to quiet" do
shell.base = MyCounter.new [1, 2]
expect(shell.base).to receive(:options).and_return(:quiet => true)

expect($stdout).not_to receive(:print)
shell.say("Running...")
end
end

describe "#print_wrapped" do
Expand Down

0 comments on commit f9906a1

Please sign in to comment.