Sha256: c23d1fef87730ff270cf77a3728ef350b681a364be0caaaf16f7576d1f10f1a7

Contents?: true

Size: 976 Bytes

Versions: 2

Compression:

Stored size: 976 Bytes

Contents

require 'test_helper'
require 'knife-solo/config'

class KnifeSoloConfigTest < TestCase
  def setup
    super
    @config = KnifeSolo::Config.new
  end

  def teardown
    super
    FileUtils.rm_f 'solo.rb'
  end

  def test_uses_cookbook_path_from_solo_rb_if_available
    write_file('solo.rb', <<-RUBY)
      knife[:solo_path] = "./custom"
      cookbook_path ["./custom/path"]
    RUBY
    assert_equal "./custom/path", @config.cookbook_path
  end

  def test_reads_chef_root_path_from_knife_config_or_defaults_to_home
    assert_equal './chef-solo', @config.chef_path
    Chef::Config.knife[:solo_path] = "/tmp/custom-chef-solo"
    assert_equal "/tmp/custom-chef-solo", @config.chef_path
  end

  def test_fails_validation_if_user_has_solo_rb_and_no_solo_path
    Chef::Config.knife[:solo_path] = nil
    write_file('solo.rb', <<-RUBY)
        cookbook_path ["custom/path"]
    RUBY
    assert_raises KnifeSolo::Config::Error do
      @config.validate!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
knife-solo-0.3.0.pre2 test/knife-solo/config_test.rb
knife-solo-0.3.0.pre1 test/knife-solo/config_test.rb