Sha256: 5284abadaddeb72f84e787af42e96522e88c061f50409846846f60349560aaec

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

require 'chef/knife'
require 'knife-solo/deprecated_command'

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
  end

  def new_run
    # dummy
  end
end

class DummyDeprecatedCommand < DummyNewCommand
  include KnifeSolo::DeprecatedCommand
end

class DeprecatedCommandTest < TestCase
  def test_help_warns_about_deprecation
    $stdout.expects(:puts).with(regexp_matches(/deprecated!/))
    assert_exits { command("--help") }
  end

  def test_warns_about_deprecation
    cmd = command
    cmd.ui.expects(:warn).with(regexp_matches(/deprecated!/))
    cmd.run
  end

  def test_runs_new_command
    cmd = command
    cmd.ui.stubs(:warn)
    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)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
knife-solo-0.7.0 test/deprecated_command_test.rb
knife-solo-0.7.0.pre3 test/deprecated_command_test.rb
knife-solo-0.7.0.pre2 test/deprecated_command_test.rb
knife-solo-0.7.0.pre test/deprecated_command_test.rb
knife-solo-0.6.0 test/deprecated_command_test.rb
knife-solo-0.5.1 test/deprecated_command_test.rb
knife-solo-0.5.0 test/deprecated_command_test.rb