Skip to content

Commit

Permalink
Merge pull request #686 from deivid-rodriguez/fix_uninitialized_globa…
Browse files Browse the repository at this point in the history
…l_variable_warning

Fix uninitialized global variable warning
  • Loading branch information
rafaelfranca committed Nov 4, 2019
2 parents da1e707 + 731a2b3 commit 7f41bdc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/thor.rb
Expand Up @@ -398,6 +398,7 @@ def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable Me
# the namespace should be displayed as arguments.
#
def banner(command, namespace = nil, subcommand = false)
$thor_runner ||= false
command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
"#{basename} #{formatted_usage}"
end.join("\n")
Expand Down
10 changes: 10 additions & 0 deletions spec/fixtures/verbose.thor
@@ -0,0 +1,10 @@
#!/usr/bin/ruby

$VERBOSE = true

require 'thor'

class Test < Thor
end

Test.start(ARGV)
10 changes: 10 additions & 0 deletions spec/no_warnings_spec.rb
@@ -0,0 +1,10 @@
require "open3"

context "when $VERBOSE is enabled" do
it "prints no warnings" do
root = File.expand_path("..", __dir__)
_, err, _ = Open3.capture3("ruby -I #{root}/lib #{root}/spec/fixtures/verbose.thor")

expect(err).to be_empty
end
end

0 comments on commit 7f41bdc

Please sign in to comment.