knife-block 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ class Chef
15
15
  # locate_config_file is only compatible with Chef 11
16
16
  _chef11 = ::Chef::Version.new('11.0.0')
17
17
  if GreenAndSecure.current_chef_version >= _chef11
18
- locate_config_file if not config[:config_file]
18
+ config[:config_file] ||= ::Chef::Knife.locate_config_file
19
19
  else
20
20
  GreenAndSecure.locate_config_file config
21
21
  end
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Block
3
- VERSION = "0.0.9"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -5,12 +5,40 @@
5
5
  require 'chef/knife'
6
6
  require './lib/chef/knife/block'
7
7
  require 'test/unit'
8
+ require 'fileutils'
8
9
 
9
- class TestKnifeBlock < Test::Unit::TestCase
10
+ class TestGreenAndSecureModule < Test::Unit::TestCase
10
11
 
11
- def test_list_file
12
- chef_path = "#{ENV['WORKSPACE']}/.chef/"
13
- knifeblock = GreenAndSecure::BlockList.new
14
- assert(!File.symlink?(chef_path+"/knife.rb"), "Knife.rb was not a symlink")
12
+ def setup
13
+ @green = Object.new
14
+ class << @green
15
+ include GreenAndSecure
15
16
  end
17
+
18
+ ENV['WORKSPACE'] ? (@chef_path ||= "#{ENV['WORKSPACE']}/.chef") : @chef_path = "#{ENV['HOME']}/.chef"
19
+ if ENV['TRAVIS']
20
+ @knife_ci = "#{@chef_path}/knife-ci.rb"
21
+ FileUtils.mkpath(@chef_path) unless File.exists?(@chef_path)
22
+ FileUtils.touch("#{@knife_ci}") unless File.exists?("#{@knife_ci}")
23
+ FileUtils.ln_s("#{@knife_ci}","#{@chef_path}/knife.rb") unless File.exists?("#{@chef_path}/knife.rb")
24
+ end
25
+ end
26
+
27
+ def teardown
28
+ if ENV['TRAVIS']
29
+ FileUtils.remove_entry_secure(@chef_path, force = true) if File.exists?(@chef_path)
30
+ end
31
+ end
32
+
33
+ def test_001_it_detects_a_version
34
+ assert_match(/\d+\.\d+\.\d+/,@green.current_chef_version.to_s, "FAIL: Chef version undetected!")
35
+ end
36
+
37
+ def test_002_it_locates_a_knife_config
38
+ assert_match(/.*\/.chef\/knife\.rb/,@green.chef_config_base+"/knife.rb", "FAIL: knife.rb not found!")
39
+ end
40
+
41
+ def test_003_knife_rb_is_a_symlink
42
+ assert(File.symlink?(@chef_path+"/knife.rb"), "knife.rb was not a symlink, please link it to #{@chef_path}/knife-<servername>.rb")
43
+ end
16
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-25 00:00:00.000000000 Z
12
+ date: 2013-12-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Create and manage knife.rb files for OpsCodes' Chef
15
15
  email: