Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #233 from tmatilai/fix-deprecated-commands
Browse files Browse the repository at this point in the history
Fix deprecated commands
  • Loading branch information
tmatilai committed Apr 21, 2013
2 parents 2e4adde + b83f4ea commit f2f2673
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/knife-solo/deprecated_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ def self.deprecated
end

banner deprecated
self.options = superclass.options

def self.load_deps
superclass.load_deps
end
end
end

Expand Down
15 changes: 14 additions & 1 deletion test/deprecated_command_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
class DummyNewCommand < Chef::Knife
banner "knife dummy_new_command"

option :foo,
:long => '--foo',
:description => 'Foo option'

def run
# calls #new_run so we can be sure this gets called
new_run
Expand All @@ -32,13 +36,22 @@ def test_warns_about_deprecation
cmd.run
end

def test_runs_original_command
def test_runs_new_command
cmd = command
cmd.ui.stubs(:err)
cmd.expects(:new_run)
cmd.run
end

def test_includes_options_from_new_command
assert DummyDeprecatedCommand.options.include?(:foo)
end

def test_loads_dependencies_from_new_command
DummyNewCommand.expects(:load_deps)
DummyDeprecatedCommand.load_deps
end

def command(*args)
DummyDeprecatedCommand.load_deps
DummyDeprecatedCommand.new(args)
Expand Down

0 comments on commit f2f2673

Please sign in to comment.