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

Fix deprecated commands #233

Merged
merged 3 commits into from
Apr 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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