berkshelf 2.0.18 → 3.0.0.beta1

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.
Files changed (128) hide show
  1. data/.ruby-version +1 -1
  2. data/.travis.yml +4 -1
  3. data/CHANGELOG.md +2 -26
  4. data/Gemfile +12 -2
  5. data/README.md +9 -1
  6. data/berkshelf.gemspec +9 -18
  7. data/bin/berks +3 -13
  8. data/features/apply_command.feature +11 -9
  9. data/features/berksfile.feature +8 -10
  10. data/features/config.feature +1 -2
  11. data/features/configure_command.feature +13 -14
  12. data/features/contingent_command.feature +13 -1
  13. data/features/cookbook_command.feature +2 -4
  14. data/features/groups_install.feature +10 -2
  15. data/features/help.feature +1 -1
  16. data/features/init_command.feature +5 -7
  17. data/features/install_command.feature +157 -228
  18. data/features/json_formatter.feature +27 -15
  19. data/features/licenses.feature +18 -12
  20. data/features/list_command.feature +6 -1
  21. data/features/lockfile.feature +116 -72
  22. data/features/outdated_command.feature +3 -47
  23. data/features/package_command.feature +10 -7
  24. data/features/shelf/show.feature +2 -2
  25. data/features/shelf/uninstall.feature +2 -2
  26. data/features/show_command.feature +10 -3
  27. data/features/step_definitions/chef/config_steps.rb +12 -0
  28. data/features/step_definitions/chef_server_steps.rb +16 -16
  29. data/features/step_definitions/cli_steps.rb +3 -79
  30. data/features/step_definitions/config_steps.rb +43 -0
  31. data/features/step_definitions/environment_steps.rb +7 -0
  32. data/features/step_definitions/filesystem_steps.rb +12 -57
  33. data/features/step_definitions/gem_steps.rb +1 -2
  34. data/features/step_definitions/json_steps.rb +3 -1
  35. data/features/step_definitions/lockfile_steps.rb +4 -0
  36. data/features/step_definitions/utility_steps.rb +0 -19
  37. data/features/support/aruba.rb +12 -0
  38. data/features/support/env.rb +52 -57
  39. data/features/update_command.feature +37 -23
  40. data/features/upload_command.feature +96 -160
  41. data/generator_files/Berksfile.erb +2 -1
  42. data/generator_files/Vagrantfile.erb +3 -0
  43. data/generator_files/default_test.rb.erb +1 -1
  44. data/generator_files/helpers.rb.erb +1 -1
  45. data/lib/berkshelf.rb +43 -24
  46. data/lib/berkshelf/api_client.rb +67 -0
  47. data/lib/berkshelf/api_client/remote_cookbook.rb +42 -0
  48. data/lib/berkshelf/berksfile.rb +232 -420
  49. data/lib/berkshelf/cached_cookbook.rb +22 -10
  50. data/lib/berkshelf/chef/config.rb +1 -0
  51. data/lib/berkshelf/cli.rb +66 -68
  52. data/lib/berkshelf/commands/shelf.rb +1 -1
  53. data/lib/berkshelf/community_rest.rb +10 -17
  54. data/lib/berkshelf/config.rb +23 -27
  55. data/lib/berkshelf/cookbook_generator.rb +3 -4
  56. data/lib/berkshelf/cookbook_store.rb +74 -17
  57. data/lib/berkshelf/core_ext/file.rb +2 -2
  58. data/lib/berkshelf/core_ext/pathname.rb +7 -5
  59. data/lib/berkshelf/{cookbook_source.rb → dependency.rb} +47 -67
  60. data/lib/berkshelf/downloader.rb +49 -106
  61. data/lib/berkshelf/errors.rb +64 -71
  62. data/lib/berkshelf/formatters.rb +11 -9
  63. data/lib/berkshelf/formatters/human_readable.rb +9 -9
  64. data/lib/berkshelf/formatters/json.rb +14 -4
  65. data/lib/berkshelf/init_generator.rb +3 -3
  66. data/lib/berkshelf/installer.rb +136 -0
  67. data/lib/berkshelf/location.rb +91 -131
  68. data/lib/berkshelf/locations/git_location.rb +9 -11
  69. data/lib/berkshelf/locations/github_location.rb +1 -1
  70. data/lib/berkshelf/locations/path_location.rb +10 -27
  71. data/lib/berkshelf/lockfile.rb +92 -70
  72. data/lib/berkshelf/logger.rb +4 -7
  73. data/lib/berkshelf/mixin/config.rb +21 -4
  74. data/lib/berkshelf/resolver.rb +60 -150
  75. data/lib/berkshelf/resolver/graph.rb +44 -0
  76. data/lib/berkshelf/source.rb +55 -0
  77. data/lib/berkshelf/source_uri.rb +38 -0
  78. data/lib/berkshelf/version.rb +1 -1
  79. data/spec/config/knife.rb +1 -1
  80. data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_dependency_as_dependencies.yml +3694 -0
  81. data/spec/fixtures/cookbooks/example_cookbook/Berksfile.lock +1 -1
  82. data/spec/fixtures/lockfiles/default.lock +1 -1
  83. data/spec/spec_helper.rb +20 -121
  84. data/spec/support/chef_api.rb +3 -4
  85. data/spec/support/chef_server.rb +20 -11
  86. data/spec/support/git.rb +127 -0
  87. data/spec/support/kitchen.rb +12 -0
  88. data/spec/support/path_helpers.rb +69 -0
  89. data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
  90. data/spec/unit/berkshelf/api_client_spec.rb +57 -0
  91. data/spec/unit/berkshelf/berksfile_spec.rb +206 -324
  92. data/spec/unit/berkshelf/cached_cookbook_spec.rb +73 -38
  93. data/spec/unit/berkshelf/community_rest_spec.rb +30 -71
  94. data/spec/unit/berkshelf/config_spec.rb +3 -14
  95. data/spec/unit/berkshelf/cookbook_generator_spec.rb +1 -2
  96. data/spec/unit/berkshelf/cookbook_store_spec.rb +12 -7
  97. data/spec/unit/berkshelf/dependency_spec.rb +285 -0
  98. data/spec/unit/berkshelf/downloader_spec.rb +4 -183
  99. data/spec/unit/berkshelf/formatters/null_spec.rb +1 -1
  100. data/spec/unit/berkshelf/formatters_spec.rb +4 -2
  101. data/spec/unit/berkshelf/git_spec.rb +15 -15
  102. data/spec/unit/berkshelf/installer_spec.rb +39 -0
  103. data/spec/unit/berkshelf/location_spec.rb +87 -114
  104. data/spec/unit/berkshelf/locations/git_location_spec.rb +41 -53
  105. data/spec/unit/berkshelf/locations/path_location_spec.rb +13 -23
  106. data/spec/unit/berkshelf/lockfile_spec.rb +38 -40
  107. data/spec/unit/berkshelf/resolver/graph_spec.rb +44 -0
  108. data/spec/unit/berkshelf/resolver_spec.rb +34 -83
  109. data/spec/unit/berkshelf/source_spec.rb +23 -0
  110. data/spec/unit/berkshelf/source_uri_spec.rb +29 -0
  111. metadata +149 -188
  112. checksums.yaml +0 -7
  113. data/features/default_locations.feature +0 -127
  114. data/features/step_definitions/berksfile_steps.rb +0 -8
  115. data/features/step_definitions/configure_cli_steps.rb +0 -19
  116. data/features/vendor_install.feature +0 -19
  117. data/lib/berkshelf/core_ext/openuri.rb +0 -36
  118. data/lib/berkshelf/core_ext/rbzip2.rb +0 -8
  119. data/lib/berkshelf/locations/chef_api_location.rb +0 -228
  120. data/lib/berkshelf/locations/site_location.rb +0 -92
  121. data/lib/berkshelf/test.rb +0 -35
  122. data/spec/knife.rb.sample +0 -12
  123. data/spec/support/test_generators.rb +0 -27
  124. data/spec/unit/berkshelf/cli_spec.rb +0 -16
  125. data/spec/unit/berkshelf/cookbook_source_spec.rb +0 -358
  126. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +0 -46
  127. data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +0 -139
  128. data/spec/unit/berkshelf/locations/site_location_spec.rb +0 -19
@@ -1,4 +1,4 @@
1
1
  {
2
- "sources": {
2
+ "dependencies": {
3
3
  }
4
4
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "sha":"6b76225554cc1f7c0aea0f8b3f10c6743aeba67e",
3
- "sources":{
3
+ "dependencies":{
4
4
  "build-essential":{
5
5
  "locked_version":"1.1.2"
6
6
  },
@@ -1,22 +1,12 @@
1
- # We set this variable to load additional test materials during cucumber
2
- # runs, since aruba runs in a subprocess. See lib/berkshelf/test.rb
3
- ENV['RUBY_ENV'] ||= 'test'
4
-
5
- require 'rubygems'
6
- require 'bundler'
7
1
  require 'spork'
8
2
 
9
3
  Spork.prefork do
10
- require 'pp'
11
4
  require 'rspec'
12
5
  require 'webmock/rspec'
13
6
  require 'vcr'
7
+ require 'berkshelf/api/rspec'
14
8
 
15
- APP_ROOT = File.expand_path('../../', __FILE__)
16
- ENV["BERKSHELF_PATH"] = File.join(APP_ROOT, "spec", "tmp", "berkshelf")
17
- ENV["BERKSHELF_CHEF_CONFIG"] = File.join(APP_ROOT, "spec", "config", "knife.rb")
18
-
19
- Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each {|f| require f}
9
+ Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) }
20
10
 
21
11
  VCR.configure do |config|
22
12
  config.configure_rspec_metadata!
@@ -30,8 +20,10 @@ Spork.prefork do
30
20
  config.include Berkshelf::RSpec::FileSystemMatchers
31
21
  config.include Berkshelf::RSpec::ChefAPI
32
22
  config.include Berkshelf::RSpec::ChefServer
23
+ config.include Berkshelf::RSpec::Git
24
+ config.include Berkshelf::RSpec::PathHelpers
25
+ config.include Berkshelf::API::RSpec
33
26
 
34
- # Disallow should syntax
35
27
  config.expect_with :rspec do |c|
36
28
  c.syntax = :expect
37
29
  end
@@ -42,25 +34,27 @@ Spork.prefork do
42
34
  config.run_all_when_everything_filtered = true
43
35
 
44
36
  config.before(:suite) do
45
- Berkshelf::RSpec::ChefServer.start
46
37
  WebMock.disable_net_connect!(allow_localhost: true, net_http_connect_on_start: true)
38
+ Berkshelf::RSpec::ChefServer.start
39
+ Berkshelf::API::RSpec::Server.start
40
+ Berkshelf.set_format(:null)
41
+ Berkshelf.ui.mute!
47
42
  end
48
43
 
49
44
  config.after(:suite) do
50
- Berkshelf::RSpec::ChefServer.stop
45
+ Berkshelf.ui.unmute!
51
46
  end
52
47
 
53
- config.before(:each) do
54
- Celluloid.shutdown
55
- Celluloid.boot
56
- clean_tmp_path
57
- Berkshelf.cookbook_store = Berkshelf::CookbookStore.new(tmp_path.join("downloader_tmp"))
58
- Berkshelf.set_format(:null)
59
- Berkshelf.ui.mute!
48
+ config.before(:all) do
49
+ ENV['BERKSHELF_PATH'] = berkshelf_path.to_s
60
50
  end
61
51
 
62
- config.after(:each) do
63
- Berkshelf.ui.unmute!
52
+ config.before(:each) do
53
+ Berkshelf::API::RSpec::Server.clear_cache
54
+ clean_tmp_path
55
+ Berkshelf.initialize_filesystem
56
+ Berkshelf::CookbookStore.instance.initialize_filesystem
57
+ reload_configs
64
58
  end
65
59
  end
66
60
 
@@ -76,102 +70,6 @@ Spork.prefork do
76
70
 
77
71
  result
78
72
  end
79
-
80
- def example_cookbook_from_path
81
- @example_cookbook_from_path ||= Berkshelf::Cookbook.new('example_cookbook', path: File.join(File.dirname(__FILE__), 'fixtures', 'cookbooks'))
82
- end
83
-
84
- def app_root_path
85
- Pathname.new(APP_ROOT)
86
- end
87
-
88
- def tmp_path
89
- app_root_path.join('spec/tmp')
90
- end
91
-
92
- def fixtures_path
93
- app_root_path.join('spec/fixtures')
94
- end
95
-
96
- def clean_tmp_path
97
- FileUtils.rm_rf(tmp_path)
98
- FileUtils.mkdir_p(tmp_path)
99
- end
100
-
101
- def git_origin_for(repo, options = {})
102
- "file://#{generate_fake_git_remote("git@github.com/RiotGames/#{repo}.git", options)}/.git"
103
- end
104
-
105
- def generate_fake_git_remote(uri, options = {})
106
- remote_bucket = Pathname.new(::File.dirname(__FILE__)).join('tmp', 'remote_repos')
107
- FileUtils.mkdir_p(remote_bucket)
108
-
109
- repo_name = uri.to_s.split('/').last.split('.')
110
- name = if repo_name.last == 'git'
111
- repo_name.first
112
- else
113
- repo_name.last
114
- end
115
- name = 'rspec_cookbook' if name.nil? or name.empty?
116
-
117
- path = ''
118
- capture(:stdout) do
119
- Dir.chdir(remote_bucket) do
120
- Berkshelf::Cli.new.invoke(:cookbook, [name], skip_vagrant: true, skip_test_kitchen: true, force: true)
121
- end
122
-
123
- Dir.chdir(path = remote_bucket.join(name)) do
124
- run! "git config receive.denyCurrentBranch ignore"
125
- run! "echo '# a change!' >> content_file"
126
- run! "git add ."
127
- run "git commit -am 'A commit.'"
128
- options[:tags].each do |tag|
129
- run! "echo '#{tag}' > content_file"
130
- run! "git add content_file"
131
- run "git commit -am '#{tag} content'"
132
- run "git tag '#{tag}' 2> /dev/null"
133
- end if options.has_key? :tags
134
- options[:branches].each do |branch|
135
- run! "git checkout -b #{branch} master 2> /dev/null"
136
- run! "echo '#{branch}' > content_file"
137
- run! "git add content_file"
138
- run "git commit -am '#{branch} content'"
139
- run "git checkout master 2> /dev/null"
140
- end if options.has_key? :branches
141
- end
142
- end
143
- path
144
- end
145
-
146
- def git_sha_for_ref(repo, ref)
147
- Dir.chdir local_git_origin_path_for(repo) do
148
- run!("git show-ref '#{ref}'").chomp.split(/\s/).first
149
- end
150
- end
151
-
152
- def local_git_origin_path_for(repo)
153
- remote_repos_path = tmp_path.join('remote_repos')
154
- FileUtils.mkdir_p(remote_repos_path)
155
- remote_repos_path.join(repo)
156
- end
157
-
158
- def clone_target
159
- tmp_path.join('clone_targets')
160
- end
161
-
162
- def clone_target_for(repo)
163
- clone_target.join(repo)
164
- end
165
-
166
- def run!(cmd)
167
- out = `#{cmd}`
168
- raise "#{cmd} did not succeed:\n\tstatus: #{$?.exitstatus}\n\toutput: #{out}" unless $?.success?
169
- out
170
- end
171
-
172
- def run(cmd)
173
- `#{cmd}`
174
- end
175
73
  end
176
74
 
177
75
  Spork.each_run do
@@ -179,6 +77,8 @@ Spork.each_run do
179
77
 
180
78
  module Berkshelf
181
79
  class GitLocation
80
+ include Berkshelf::RSpec::Git
81
+
182
82
  alias :real_clone :clone
183
83
  def clone
184
84
  fake_remote = generate_fake_git_remote(uri, tags: @branch ? [@branch] : [])
@@ -189,4 +89,3 @@ Spork.each_run do
189
89
  end
190
90
  end
191
91
  end
192
-
@@ -50,7 +50,6 @@ module Berkshelf
50
50
  "templates/default",
51
51
  "files/default",
52
52
  "attributes",
53
- "definitions",
54
53
  "providers",
55
54
  "resources"
56
55
  ]
@@ -116,9 +115,9 @@ module Berkshelf
116
115
 
117
116
  def ridley
118
117
  @ridley ||= Ridley.new(
119
- server_url: Berkshelf.chef_config[:chef_server_url],
120
- client_name: Berkshelf.chef_config[:node_name],
121
- client_key: Berkshelf.chef_config[:client_key],
118
+ server_url: Berkshelf::RSpec::ChefServer.server_url,
119
+ client_name: Berkshelf.chef_config[:node_name],
120
+ client_key: Berkshelf.chef_config[:client_key],
122
121
  ssl: { verify: false }
123
122
  )
124
123
  end
@@ -1,10 +1,13 @@
1
1
  require 'chef_zero/server'
2
+ require 'json'
2
3
 
3
4
  module Berkshelf::RSpec
4
5
  module ChefServer
5
- PORT = 8889
6
+ PORT = 4000
6
7
 
7
8
  class << self
9
+ attr_reader :server
10
+
8
11
  def clear_request_log
9
12
  @request_log = Array.new
10
13
  end
@@ -13,22 +16,24 @@ module Berkshelf::RSpec
13
16
  @request_log ||= Array.new
14
17
  end
15
18
 
16
- def server
17
- @server ||= ChefZero::Server.new(port: PORT, generate_real_keys: false)
18
- end
19
-
20
19
  def server_url
21
- (@server && @server.url) || "http://localhost:#{PORT}"
20
+ @server && @server.url
22
21
  end
23
22
 
24
- def start
25
- server.start_background
26
- server.on_response do |request, response|
23
+ def start(options = {})
24
+ return @server if @server
25
+
26
+ options = options.reverse_merge(port: PORT)
27
+ options[:generate_real_keys] = false
28
+
29
+ @server = ChefZero::Server.new(options)
30
+ @server.start_background
31
+ @server.on_response do |request, response|
27
32
  request_log << [ request, response ]
28
33
  end
29
34
  clear_request_log
30
35
 
31
- server
36
+ @server
32
37
  end
33
38
 
34
39
  def stop
@@ -38,6 +43,10 @@ module Berkshelf::RSpec
38
43
  def running?
39
44
  @server && @server.running?
40
45
  end
46
+
47
+ def reset!
48
+ @server && @server.clear_data
49
+ end
41
50
  end
42
51
 
43
52
  def chef_server
@@ -67,7 +76,7 @@ module Berkshelf::RSpec
67
76
  private
68
77
 
69
78
  def load_data(key, name, hash)
70
- ChefServer.server.load_data({ key.to_s => { name => MultiJson.encode(hash) }})
79
+ ChefServer.server.load_data({ key.to_s => { name => JSON.generate(hash) }})
71
80
  end
72
81
  end
73
82
  end
@@ -0,0 +1,127 @@
1
+ module Berkshelf
2
+ module RSpec
3
+ module Git
4
+ require 'buff/shell_out'
5
+ include Buff::ShellOut
6
+
7
+ require_relative 'path_helpers'
8
+ include Berkshelf::RSpec::PathHelpers
9
+
10
+ def git_origin_for(repo, options = {})
11
+ "file://#{generate_fake_git_remote("git@github.com/RiotGames/#{repo}.git", options)}/.git"
12
+ end
13
+
14
+ def generate_fake_git_remote(uri, options = {})
15
+ name = uri.split('/').last || 'rspec_cookbook'
16
+ name = name.gsub('.git', '')
17
+ path = remotes.join(name)
18
+
19
+ capture(:stdout) do
20
+ Dir.chdir(remotes) { generate_git_cookbook(name) }
21
+
22
+ Dir.chdir(path) do
23
+ shell_out "git config receive.denyCurrentBranch ignore"
24
+ shell_out "echo '# a change!' >> content_file"
25
+ shell_out "git add ."
26
+ shell_out "git commit -am 'A commit.'"
27
+
28
+ options[:tags].each do |tag|
29
+ shell_out "echo '#{tag}' > content_file"
30
+ shell_out "git add content_file"
31
+ shell_out "git commit -am '#{tag} content'"
32
+ shell_out "git tag '#{tag}' 2> /dev/null"
33
+ end if options[:tags]
34
+
35
+ options[:branches].each do |branch|
36
+ shell_out "git checkout -b #{branch} master 2> /dev/null"
37
+ shell_out "echo '#{branch}' > content_file"
38
+ shell_out "git add content_file"
39
+ shell_out "git commit -am '#{branch} content'"
40
+ shell_out "git checkout master 2> /dev/null"
41
+ end if options[:branches]
42
+ end
43
+ end
44
+
45
+ path
46
+ end
47
+
48
+ # Calculate the git sha for the given ref.
49
+ #
50
+ # @param [#to_s] repo
51
+ # the repository to show the ref for
52
+ # @param [#to_s] ref
53
+ # the ref to show
54
+ #
55
+ # @return [String]
56
+ def sha_for_ref(repo, ref)
57
+ Dir.chdir(remote_path(repo)) do
58
+ shell_out("git show-ref #{ref}").stdout.split(/\s/).first
59
+ end
60
+ end
61
+
62
+ # The clone path the given repo.
63
+ #
64
+ # @param [#to_s] repo
65
+ # the name of the local repo
66
+ #
67
+ # @return [Pathname]
68
+ # the path to the clone
69
+ def clone_path(repo)
70
+ clones.join(repo.to_s)
71
+ end
72
+
73
+ # The clone path the remote repo.
74
+ #
75
+ # @param [#to_s] repo
76
+ # the name of the remote repo
77
+ #
78
+ # @return [Pathname]
79
+ # the path to the clone
80
+ def remote_path(repo)
81
+ remotes.join(repo.to_s)
82
+ end
83
+
84
+ private
85
+ # The path to store the local git clones.
86
+ #
87
+ # @return [Pathname]
88
+ def clones
89
+ ensure_and_return(tmp_path.join('clones'))
90
+ end
91
+
92
+ # The path to store the git remotes.
93
+ #
94
+ # @return [Pathname]
95
+ def remotes
96
+ ensure_and_return(tmp_path.join('remotes'))
97
+ end
98
+
99
+ # Generate a cookbook by the given name.
100
+ #
101
+ # @param [#to_s] name
102
+ # the name of the cookbook to create
103
+ # @param [Hash] options
104
+ # the list ooptions to pass to the generator
105
+ def generate_git_cookbook(name, options = {})
106
+ options = {
107
+ skip_vagrant: true,
108
+ skip_test_kitchen: true,
109
+ force: true,
110
+ }.merge(options)
111
+
112
+ Berkshelf::Cli.new.invoke(:cookbook, [name.to_s], options)
113
+ end
114
+
115
+ # Make sure the given path exists and return the path
116
+ #
117
+ # @param [#to_s] path
118
+ # the path to create and return
119
+ #
120
+ # @return [Pathname]
121
+ def ensure_and_return(path)
122
+ FileUtils.mkdir(path) unless File.exist?(path)
123
+ return Pathname.new(path).expand_path
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,12 @@
1
+ module Berkshelf
2
+ module RSpec
3
+ module Kitchen
4
+ require 'kitchen/generator/init'
5
+
6
+ def stub_kitchen!
7
+ generator = double('kitchen-generator', invoke_all: nil)
8
+ ::Kitchen::Generator::Init.stub(:new).with(any_args()).and_return(generator)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,69 @@
1
+ module Berkshelf
2
+ module RSpec
3
+ module PathHelpers
4
+ # The path to where berkshelf lives (tmp/berkshelf)
5
+ #
6
+ # @return [Pathname]
7
+ def berkshelf_path
8
+ tmp_path.join('berkshelf').expand_path
9
+ end
10
+
11
+ # The Berkshelf cookbook store
12
+ #
13
+ # @return [Berkshelf::CookbookStore]
14
+ def cookbook_store
15
+ Berkshelf.cookbook_store
16
+ end
17
+
18
+ # The tmp path where testing support/workspaces are
19
+ #
20
+ # @return [Pathname]
21
+ def tmp_path
22
+ Berkshelf.root.join('spec/tmp')
23
+ end
24
+
25
+ # The path to the spec fixtures
26
+ #
27
+ # @return [Pathname]
28
+ def fixtures_path
29
+ Berkshelf.root.join('spec/fixtures')
30
+ end
31
+
32
+ # The path to the Chef config fixture
33
+ #
34
+ # @return [String]
35
+ def chef_config_path
36
+ Berkshelf.root.join('spec/config/knife.rb').to_s
37
+ end
38
+
39
+ # The actual Chef config object
40
+ #
41
+ # @return [Bershelf::Chef::Config]
42
+ def chef_config
43
+ Berkshelf::Chef::Config.from_file(chef_config_path)
44
+ end
45
+
46
+ def clean_tmp_path
47
+ FileUtils.rm_rf(tmp_path)
48
+ FileUtils.mkdir_p(tmp_path)
49
+ end
50
+
51
+ private
52
+
53
+ # This is the magical "reset" function that gives us a clean working
54
+ # directory on each run.
55
+ #
56
+ # @return [nil]
57
+ def reload_configs
58
+ Berkshelf.chef_config = chef_config
59
+
60
+ # This fucking sucks...
61
+ load 'berkshelf/chef/config.rb'
62
+ load 'berkshelf/config.rb'
63
+
64
+ Berkshelf.config = Berkshelf::Config.new
65
+ nil
66
+ end
67
+ end
68
+ end
69
+ end