Skip to content

Commit 7f41bdc

Browse files
authored
Merge pull request #686 from deivid-rodriguez/fix_uninitialized_global_variable_warning
Fix uninitialized global variable warning
2 parents da1e707 + 731a2b3 commit 7f41bdc

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/thor.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable Me
398398
# the namespace should be displayed as arguments.
399399
#
400400
def banner(command, namespace = nil, subcommand = false)
401+
$thor_runner ||= false
401402
command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
402403
"#{basename} #{formatted_usage}"
403404
end.join("\n")

spec/fixtures/verbose.thor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/ruby
2+
3+
$VERBOSE = true
4+
5+
require 'thor'
6+
7+
class Test < Thor
8+
end
9+
10+
Test.start(ARGV)

spec/no_warnings_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require "open3"
2+
3+
context "when $VERBOSE is enabled" do
4+
it "prints no warnings" do
5+
root = File.expand_path("..", __dir__)
6+
_, err, _ = Open3.capture3("ruby -I #{root}/lib #{root}/spec/fixtures/verbose.thor")
7+
8+
expect(err).to be_empty
9+
end
10+
end

0 commit comments

Comments
 (0)