Sha256: b67fcf6c056a5de3b00bd951689076f23dd144d30e0f63aab092201e7de00364

Contents?: true

Size: 915 Bytes

Versions: 7

Compression:

Stored size: 915 Bytes

Contents

require 'test_helper'

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

class DummyNewCommand < Chef::Knife
  banner "knife dummy_new_command"

  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(:err).with(regexp_matches(/deprecated!/))
    cmd.run
  end

  def test_runs_original_command
    cmd = command
    cmd.ui.stubs(:err)
    cmd.expects(:new_run)
    cmd.run
  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.3.0.pre3 test/deprecated_command_test.rb
knife-solo-0.3.0.pre2 test/deprecated_command_test.rb
knife-solo-0.3.0.pre1 test/deprecated_command_test.rb
knife-solo-0.2.0 test/deprecated_command_test.rb
knife-solo-0.2.0.pre1 test/deprecated_command_test.rb
knife-solo-0.1.0 test/deprecated_command_test.rb
knife-solo-0.1.0.pre1 test/deprecated_command_test.rb