Skip to content

Commit 6bc70b6

Browse files
committed
Merge pull request #452 from bronzle/fix_remove_command
use merge! (with bang) to ensure that cached @all_commands can be modified
2 parents 919e13a + ef1eb07 commit 6bc70b6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/thor/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def commands
343343
#
344344
def all_commands
345345
@all_commands ||= from_superclass(:all_commands, Thor::CoreExt::OrderedHash.new)
346-
@all_commands.merge(commands)
346+
@all_commands.merge!(commands)
347347
end
348348
alias_method :all_tasks, :all_commands
349349

spec/base_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def hello
228228

229229
describe "#remove_command" do
230230
it "removes the command from its commands hash" do
231-
expect(MyChildScript.commands.keys).not_to include("bar")
231+
expect(MyChildScript.all_commands.keys).not_to include("name_with_dashes")
232232
expect(MyChildScript.commands.keys).not_to include("boom")
233233
end
234234

spec/fixtures/script.thor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ END
118118
end
119119

120120
class MyChildScript < MyScript
121-
remove_command :bar
121+
remove_command :name_with_dashes
122122

123123
method_options :force => :boolean, :param => :numeric
124124
def initialize(*args)

0 commit comments

Comments
 (0)