vagrant 0.7.0.beta → 0.7.0.beta2

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 (86) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.md +26 -0
  3. data/Gemfile +0 -8
  4. data/config/default.rb +1 -2
  5. data/contrib/README.md +12 -0
  6. data/contrib/emacs/vagrant.el +8 -0
  7. data/contrib/vim/vagrantfile.vim +9 -0
  8. data/lib/vagrant.rb +14 -18
  9. data/lib/vagrant/action.rb +12 -0
  10. data/lib/vagrant/action/box.rb +11 -0
  11. data/lib/vagrant/action/box/download.rb +0 -1
  12. data/lib/vagrant/action/env.rb +7 -0
  13. data/lib/vagrant/action/general.rb +8 -0
  14. data/lib/vagrant/action/vm.rb +30 -0
  15. data/lib/vagrant/action/vm/boot.rb +3 -2
  16. data/lib/vagrant/action/vm/check_box.rb +1 -0
  17. data/lib/vagrant/action/vm/network.rb +1 -1
  18. data/lib/vagrant/action/vm/nfs.rb +3 -1
  19. data/lib/vagrant/action/vm/provision.rb +14 -25
  20. data/lib/vagrant/action/vm/share_folders.rb +11 -4
  21. data/lib/vagrant/command.rb +25 -0
  22. data/lib/vagrant/config.rb +78 -128
  23. data/lib/vagrant/config/base.rb +17 -3
  24. data/lib/vagrant/config/ssh.rb +1 -0
  25. data/lib/vagrant/config/top.rb +61 -0
  26. data/lib/vagrant/config/vagrant.rb +1 -6
  27. data/lib/vagrant/config/vm.rb +34 -20
  28. data/lib/vagrant/config/vm/provisioner.rb +56 -0
  29. data/lib/vagrant/config/vm/sub_vm.rb +17 -0
  30. data/lib/vagrant/downloaders.rb +7 -0
  31. data/lib/vagrant/downloaders/file.rb +1 -0
  32. data/lib/vagrant/downloaders/http.rb +9 -0
  33. data/lib/vagrant/environment.rb +25 -13
  34. data/lib/vagrant/errors.rb +0 -15
  35. data/lib/vagrant/hosts.rb +7 -0
  36. data/lib/vagrant/provisioners.rb +8 -0
  37. data/lib/vagrant/provisioners/base.rb +19 -1
  38. data/lib/vagrant/provisioners/chef.rb +31 -52
  39. data/lib/vagrant/provisioners/chef_server.rb +34 -10
  40. data/lib/vagrant/provisioners/chef_solo.rb +31 -9
  41. data/lib/vagrant/provisioners/puppet.rb +70 -60
  42. data/lib/vagrant/provisioners/puppet_server.rb +57 -0
  43. data/lib/vagrant/ssh.rb +3 -72
  44. data/lib/vagrant/ssh/session.rb +81 -0
  45. data/lib/vagrant/systems.rb +9 -0
  46. data/lib/vagrant/systems/base.rb +16 -1
  47. data/lib/vagrant/systems/debian.rb +26 -0
  48. data/lib/vagrant/systems/gentoo.rb +27 -0
  49. data/lib/vagrant/systems/linux.rb +14 -56
  50. data/lib/vagrant/systems/linux/config.rb +21 -0
  51. data/lib/vagrant/systems/linux/error.rb +9 -0
  52. data/lib/vagrant/systems/redhat.rb +31 -0
  53. data/lib/vagrant/test_helpers.rb +1 -1
  54. data/lib/vagrant/version.rb +1 -1
  55. data/lib/vagrant/vm.rb +25 -5
  56. data/templates/chef_solo_solo.erb +11 -3
  57. data/templates/locales/en.yml +65 -25
  58. data/templates/{network_entry.erb → network_entry_debian.erb} +0 -0
  59. data/templates/network_entry_gentoo.erb +7 -0
  60. data/templates/network_entry_redhat.erb +8 -0
  61. data/test/vagrant/action/vm/check_box_test.rb +1 -0
  62. data/test/vagrant/action/vm/nfs_test.rb +7 -1
  63. data/test/vagrant/action/vm/provision_test.rb +24 -79
  64. data/test/vagrant/action/vm/share_folders_test.rb +6 -1
  65. data/test/vagrant/command/helpers_test.rb +2 -2
  66. data/test/vagrant/config/base_test.rb +0 -6
  67. data/test/vagrant/config/vagrant_test.rb +0 -8
  68. data/test/vagrant/config/vm/provisioner_test.rb +92 -0
  69. data/test/vagrant/config/vm_test.rb +8 -0
  70. data/test/vagrant/config_test.rb +49 -89
  71. data/test/vagrant/downloaders/file_test.rb +18 -4
  72. data/test/vagrant/environment_test.rb +36 -12
  73. data/test/vagrant/provisioners/base_test.rb +28 -1
  74. data/test/vagrant/provisioners/chef_server_test.rb +50 -41
  75. data/test/vagrant/provisioners/chef_solo_test.rb +39 -16
  76. data/test/vagrant/provisioners/chef_test.rb +11 -81
  77. data/test/vagrant/provisioners/puppet_server_test.rb +69 -0
  78. data/test/vagrant/provisioners/puppet_test.rb +69 -54
  79. data/test/vagrant/{ssh_session_test.rb → ssh/session_test.rb} +0 -0
  80. data/test/vagrant/ssh_test.rb +12 -1
  81. data/test/vagrant/systems/base_test.rb +18 -0
  82. data/test/vagrant/systems/linux_test.rb +2 -2
  83. data/test/vagrant/vm_test.rb +33 -5
  84. data/vagrant.gemspec +6 -5
  85. metadata +42 -16
  86. data/lib/vagrant/util/glob_loader.rb +0 -24
@@ -1,14 +1,37 @@
1
1
  require "test_helper"
2
2
 
3
3
  class BaseProvisionerTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Provisioners::Base
6
+ end
7
+
4
8
  should "include the util class so subclasses have access to it" do
5
9
  assert Vagrant::Provisioners::Base.include?(Vagrant::Util)
6
10
  end
7
11
 
12
+ context "registering provisioners" do
13
+ teardown do
14
+ @klass.registered.delete(:zomg)
15
+ end
16
+
17
+ should "not have unregistered provisioners" do
18
+ assert_nil @klass.registered[:foo]
19
+ end
20
+
21
+ should "be able to register a provisioner" do
22
+ foo = Class.new(@klass) do
23
+ register :zomg
24
+ end
25
+
26
+ assert_equal foo, @klass.registered[:zomg]
27
+ end
28
+ end
29
+
8
30
  context "base instance" do
9
31
  setup do
10
32
  @env = Vagrant::Action::Environment.new(vagrant_env)
11
- @base = Vagrant::Provisioners::Base.new(@env)
33
+ @config = mock("config")
34
+ @base = Vagrant::Provisioners::Base.new(@env, @config)
12
35
  end
13
36
 
14
37
  should "set the environment" do
@@ -19,6 +42,10 @@ class BaseProvisionerTest < Test::Unit::TestCase
19
42
  assert_equal @env.env.vm, @base.vm
20
43
  end
21
44
 
45
+ should "provide access to the config" do
46
+ assert_equal @config, @base.config
47
+ end
48
+
22
49
  should "implement provision! which does nothing" do
23
50
  assert_nothing_raised do
24
51
  assert @base.respond_to?(:provision!)
@@ -2,13 +2,44 @@ require "test_helper"
2
2
 
3
3
  class ChefServerProvisionerTest < Test::Unit::TestCase
4
4
  setup do
5
+ @klass = Vagrant::Provisioners::ChefServer
6
+
5
7
  @action_env = Vagrant::Action::Environment.new(vagrant_env.vms[:default].env)
6
8
 
7
- @action = Vagrant::Provisioners::ChefServer.new(@action_env)
9
+ @config = @klass::Config.new
10
+ @action = @klass.new(@action_env, @config)
8
11
  @env = @action.env
9
12
  @vm = @action.vm
10
13
  end
11
14
 
15
+ context "config validation" do
16
+ setup do
17
+ @errors = Vagrant::Config::ErrorRecorder.new
18
+
19
+ @config.run_list = ["foo"]
20
+ @config.chef_server_url = "foo"
21
+ @config.validation_key_path = "foo"
22
+ end
23
+
24
+ should "be invalid if run list is empty" do
25
+ @config.run_list = []
26
+ @config.validate(@errors)
27
+ assert !@errors.errors.empty?
28
+ end
29
+
30
+ should "be invalid if run list is empty" do
31
+ @config.chef_server_url = nil
32
+ @config.validate(@errors)
33
+ assert !@errors.errors.empty?
34
+ end
35
+
36
+ should "be invalid if run list is empty" do
37
+ @config.validation_key_path = nil
38
+ @config.validate(@errors)
39
+ assert !@errors.errors.empty?
40
+ end
41
+ end
42
+
12
43
  context "provisioning" do
13
44
  should "run the proper sequence of methods in order" do
14
45
  prov_seq = sequence("prov_seq")
@@ -29,21 +60,14 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
29
60
  end
30
61
 
31
62
  should "not raise an exception if validation_key_path is set" do
32
- @env = vagrant_env(vagrantfile(<<-vf))
33
- config.chef.validation_key_path = "7"
34
- config.chef.chef_server_url = "7"
35
- vf
63
+ @config.validation_key_path = "7"
64
+ @config.chef_server_url = "7"
36
65
 
37
- @action.stubs(:env).returns(@env)
38
66
  assert_nothing_raised { @action.prepare }
39
67
  end
40
68
 
41
69
  should "raise an exception if validation_key_path is nil" do
42
- @env = vagrant_env(vagrantfile(<<-vf))
43
- config.chef.validation_key_path = nil
44
- vf
45
-
46
- @action.stubs(:env).returns(@env)
70
+ @config.validation_key_path = nil
47
71
 
48
72
  assert_raises(Vagrant::Provisioners::Chef::ChefError) {
49
73
  @action.prepare
@@ -51,23 +75,15 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
51
75
  end
52
76
 
53
77
  should "not raise an exception if validation_key_path does exist" do
54
- @env = vagrant_env(vagrantfile(<<-vf))
55
- config.chef.validation_key_path = "#{vagrantfile(tmp_path)}"
56
- config.chef.chef_server_url = "7"
57
- vf
78
+ @config.validation_key_path = vagrantfile(tmp_path)
79
+ @config.chef_server_url = "7"
58
80
 
59
- @action.stubs(:env).returns(@env)
60
81
  assert_nothing_raised { @action.prepare }
61
82
  end
62
83
 
63
84
  should "raise an exception if validation_key_path doesn't exist" do
64
- @env = vagrant_env(vagrantfile(<<-vf))
65
- config.chef.validation_key_path = "7"
66
- config.chef.chef_server_url = "7"
67
- vf
68
-
69
- @action.stubs(:env).returns(@env)
70
- @action.stubs(:validation_key_path).returns("9")
85
+ @config.validation_key_path = "7"
86
+ @config.chef_server_url = "7"
71
87
 
72
88
  File.expects(:file?).with(@action.validation_key_path).returns(false)
73
89
  assert_raises(Vagrant::Provisioners::Chef::ChefError) {
@@ -76,21 +92,14 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
76
92
  end
77
93
 
78
94
  should "not raise an exception if chef_server_url is set" do
79
- @env = vagrant_env(vagrantfile(<<-vf))
80
- config.chef.validation_key_path = "#{vagrantfile(tmp_path)}"
81
- config.chef.chef_server_url = "7"
82
- vf
95
+ @config.validation_key_path = vagrantfile(tmp_path)
96
+ @config.chef_server_url = "7"
83
97
 
84
- @action.stubs(:env).returns(@env)
85
98
  assert_nothing_raised { @action.prepare }
86
99
  end
87
100
 
88
101
  should "raise an exception if chef_server_url is nil" do
89
- @env = vagrant_env(vagrantfile(<<-vf))
90
- config.chef.chef_server_url = nil
91
- vf
92
-
93
- @action.stubs(:env).returns(@env)
102
+ @config.chef_server_url = nil
94
103
 
95
104
  assert_raises(Vagrant::Provisioners::Chef::ChefError) {
96
105
  @action.prepare
@@ -101,7 +110,7 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
101
110
  context "creating the client key folder" do
102
111
  setup do
103
112
  @raw_path = "/foo/bar/baz.pem"
104
- @env.config.chef.client_key_path = @raw_path
113
+ @config.client_key_path = @raw_path
105
114
 
106
115
  @path = Pathname.new(@raw_path)
107
116
  end
@@ -126,7 +135,7 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
126
135
  context "the validation key path" do
127
136
  should "expand the configured key path" do
128
137
  result = mock("result")
129
- File.expects(:expand_path).with(@env.config.chef.validation_key_path, @env.root_path).once.returns(result)
138
+ File.expects(:expand_path).with(@config.validation_key_path, @env.root_path).once.returns(result)
130
139
  assert_equal result, @action.validation_key_path
131
140
  end
132
141
  end
@@ -134,7 +143,7 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
134
143
  context "the guest validation key path" do
135
144
  should "be the provisioning path joined with validation.pem" do
136
145
  result = mock("result")
137
- File.expects(:join).with(@env.config.chef.provisioning_path, "validation.pem").once.returns(result)
146
+ File.expects(:join).with(@config.provisioning_path, "validation.pem").once.returns(result)
138
147
  assert_equal result, @action.guest_validation_key_path
139
148
  end
140
149
  end
@@ -146,11 +155,11 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
146
155
 
147
156
  should "call setup_config with proper variables" do
148
157
  @action.expects(:setup_config).with("chef_server_client", "client.rb", {
149
- :node_name => @env.config.chef.node_name,
150
- :chef_server_url => @env.config.chef.chef_server_url,
151
- :validation_client_name => @env.config.chef.validation_client_name,
158
+ :node_name => @config.node_name,
159
+ :chef_server_url => @config.chef_server_url,
160
+ :validation_client_name => @config.validation_client_name,
152
161
  :validation_key => @action.guest_validation_key_path,
153
- :client_key => @env.config.chef.client_key_path
162
+ :client_key => @config.client_key_path
154
163
  })
155
164
 
156
165
  @action.setup_server_config
@@ -164,7 +173,7 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
164
173
  end
165
174
 
166
175
  should "cd into the provisioning directory and run chef client" do
167
- @ssh.expects(:exec!).with("cd #{@env.config.chef.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json").once
176
+ @ssh.expects(:exec!).with("sudo -i 'cd #{@config.provisioning_path} && chef-client -c client.rb -j dna.json'").once
168
177
  @action.run_chef_client
169
178
  end
170
179
 
@@ -2,13 +2,36 @@ require "test_helper"
2
2
 
3
3
  class ChefSoloProvisionerTest < Test::Unit::TestCase
4
4
  setup do
5
+ @klass = Vagrant::Provisioners::ChefSolo
6
+
5
7
  @action_env = Vagrant::Action::Environment.new(vagrant_env.vms[:default].env)
6
8
 
7
- @action = Vagrant::Provisioners::ChefSolo.new(@action_env)
9
+ @config = @klass::Config.new
10
+ @action = @klass.new(@action_env, @config)
8
11
  @env = @action.env
9
12
  @vm = @action.vm
10
13
  end
11
14
 
15
+ context "config validation" do
16
+ setup do
17
+ @errors = Vagrant::Config::ErrorRecorder.new
18
+ @config.run_list = ["foo"]
19
+ @config.cookbooks_path = "cookbooks"
20
+ end
21
+
22
+ should "be invalid if run list is empty" do
23
+ @config.run_list = []
24
+ @config.validate(@errors)
25
+ assert !@errors.errors.empty?
26
+ end
27
+
28
+ should "be invalid if cookbooks path is empty" do
29
+ @config.cookbooks_path = nil
30
+ @config.validate(@errors)
31
+ assert !@errors.errors.empty?
32
+ end
33
+ end
34
+
12
35
  context "preparing" do
13
36
  should "share cookbook folders" do
14
37
  @action.expects(:share_cookbook_folders).once
@@ -87,8 +110,8 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
87
110
  context "host cookbooks paths" do
88
111
  should "get folders path for configured cookbooks path" do
89
112
  result = mock("result")
90
- @env.config.chef.stubs(:cookbooks_path).returns("foo")
91
- @action.expects(:host_folder_paths).with(@env.config.chef.cookbooks_path).returns(result)
113
+ @config.stubs(:cookbooks_path).returns("foo")
114
+ @action.expects(:host_folder_paths).with(@config.cookbooks_path).returns(result)
92
115
  assert_equal result, @action.host_cookbook_paths
93
116
  end
94
117
  end
@@ -96,15 +119,15 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
96
119
  context "host roles paths" do
97
120
  should "get folders path for configured roles path" do
98
121
  result = mock("result")
99
- @env.config.chef.stubs(:roles_path).returns("foo")
100
- @action.expects(:host_folder_paths).with(@env.config.chef.roles_path).returns(result)
122
+ @config.stubs(:roles_path).returns("foo")
123
+ @action.expects(:host_folder_paths).with(@config.roles_path).returns(result)
101
124
  assert_equal result, @action.host_role_paths
102
125
  end
103
126
  end
104
127
 
105
128
  context "folder path" do
106
129
  should "return a proper path to a single folder" do
107
- expected = File.join(@env.config.chef.provisioning_path, "cookbooks-5")
130
+ expected = File.join(@config.provisioning_path, "cookbooks-5")
108
131
  assert_equal expected, @action.folder_path("cookbooks", 5)
109
132
  end
110
133
 
@@ -125,33 +148,33 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
125
148
  end
126
149
 
127
150
  should "properly format VM folder paths" do
128
- @env.config.chef.provisioning_path = "/foo"
151
+ @config.provisioning_path = "/foo"
129
152
  assert_equal "/foo/bar", @action.folders_path([:vm, "bar"], nil)
130
153
  end
131
154
  end
132
155
 
133
156
  context "cookbooks path" do
134
157
  should "return a proper path to a single cookbook" do
135
- expected = File.join(@env.config.chef.provisioning_path, "cookbooks-5")
158
+ expected = File.join(@config.provisioning_path, "cookbooks-5")
136
159
  assert_equal expected, @action.cookbook_path(5)
137
160
  end
138
161
 
139
162
  should "properly call folders path and return result" do
140
163
  result = [:a, :b, :c]
141
- @action.expects(:folders_path).with(@env.config.chef.cookbooks_path, "cookbooks").once.returns(result)
164
+ @action.expects(:folders_path).with(@config.cookbooks_path, "cookbooks").once.returns(result)
142
165
  assert_equal result.to_json, @action.cookbooks_path
143
166
  end
144
167
  end
145
168
 
146
169
  context "roles path" do
147
170
  should "return a proper path to a single role" do
148
- expected = File.join(@env.config.chef.provisioning_path, "roles-5")
171
+ expected = File.join(@config.provisioning_path, "roles-5")
149
172
  assert_equal expected, @action.role_path(5)
150
173
  end
151
174
 
152
175
  should "properly call folders path and return result" do
153
176
  result = [:a, :b, :c]
154
- @action.expects(:folders_path).with(@env.config.chef.roles_path, "roles").once.returns(result)
177
+ @action.expects(:folders_path).with(@config.roles_path, "roles").once.returns(result)
155
178
  assert_equal result.to_json, @action.roles_path
156
179
  end
157
180
  end
@@ -160,15 +183,15 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
160
183
  setup do
161
184
  @vm.ssh.stubs(:upload!)
162
185
 
163
- @env.config.chef.recipe_url = "foo/bar/baz"
186
+ @config.recipe_url = "foo/bar/baz"
164
187
  end
165
188
 
166
189
  should "call setup_config with proper variables" do
167
190
  @action.expects(:setup_config).with("chef_solo_solo", "solo.rb", {
168
- :node_name => @env.config.chef.node_name,
169
- :provisioning_path => @env.config.chef.provisioning_path,
191
+ :node_name => @config.node_name,
192
+ :provisioning_path => @config.provisioning_path,
170
193
  :cookbooks_path => @action.cookbooks_path,
171
- :recipe_url => @env.config.chef.recipe_url,
194
+ :recipe_url => @config.recipe_url,
172
195
  :roles_path => @action.roles_path
173
196
  })
174
197
 
@@ -183,7 +206,7 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
183
206
  end
184
207
 
185
208
  should "cd into the provisioning directory and run chef solo" do
186
- @ssh.expects(:exec!).with("cd #{@env.config.chef.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json").once
209
+ @ssh.expects(:exec!).with("sudo -i 'cd #{@config.provisioning_path} && chef-solo -c solo.rb -j dna.json'").once
187
210
  @action.run_chef_solo
188
211
  end
189
212
 
@@ -4,24 +4,22 @@ class ChefProvisionerTest < Test::Unit::TestCase
4
4
  setup do
5
5
  @action_env = Vagrant::Action::Environment.new(vagrant_env.vms[:default].env)
6
6
 
7
- @action = Vagrant::Provisioners::Chef.new(@action_env)
7
+ @klass = Vagrant::Provisioners::Chef
8
+ @config = @klass::Config.new
9
+ @action = @klass.new(@action_env, @config)
8
10
  @env = @action.env
9
11
  @vm = @action.vm
10
12
  end
11
13
 
12
14
  context "preparing" do
13
15
  should "error the environment" do
14
- assert_raises(Vagrant::Provisioners::Chef::ChefError) {
16
+ assert_raises(@klass::ChefError) {
15
17
  @action.prepare
16
18
  }
17
19
  end
18
20
  end
19
21
 
20
22
  context "config" do
21
- setup do
22
- @config = Vagrant::Provisioners::Chef::ChefConfig.new
23
- end
24
-
25
23
  should "not include the 'json' key in the config dump" do
26
24
  result = @config.to_json
27
25
  assert result !~ /"json":/
@@ -65,74 +63,6 @@ class ChefProvisionerTest < Test::Unit::TestCase
65
63
  @config.add_role("role[user]")
66
64
  assert_equal "role[user]", @config.run_list[0]
67
65
  end
68
-
69
- context "validation" do
70
- setup do
71
- @errors = Vagrant::Config::ErrorRecorder.new
72
- @top = @config.top = Vagrant::Config::Top.new(@env)
73
- end
74
-
75
- context "chef solo" do
76
- setup do
77
- @top.vm.provisioner = :chef_solo
78
-
79
- @config.run_list = ["foo"]
80
- @config.cookbooks_path = "cookbooks"
81
- end
82
-
83
- should "be valid if provisioner is not chef solo" do
84
- @top.vm.provisioner = nil
85
- @config.validate(@errors)
86
- assert @errors.errors.empty?
87
- end
88
-
89
- should "be invalid if run list is empty" do
90
- @config.run_list = []
91
- @config.validate(@errors)
92
- assert !@errors.errors.empty?
93
- end
94
-
95
- should "be invalid if cookbooks path is empty" do
96
- @config.cookbooks_path = nil
97
- @config.validate(@errors)
98
- assert !@errors.errors.empty?
99
- end
100
- end
101
-
102
- context "chef server" do
103
- setup do
104
- @top.vm.provisioner = :chef_server
105
-
106
- @config.run_list = ["foo"]
107
- @config.chef_server_url = "foo"
108
- @config.validation_key_path = "foo"
109
- end
110
-
111
- should "be valid if provisioner is not chef solo" do
112
- @top.vm.provisioner = nil
113
- @config.validate(@errors)
114
- assert @errors.errors.empty?
115
- end
116
-
117
- should "be invalid if run list is empty" do
118
- @config.run_list = []
119
- @config.validate(@errors)
120
- assert !@errors.errors.empty?
121
- end
122
-
123
- should "be invalid if run list is empty" do
124
- @config.chef_server_url = nil
125
- @config.validate(@errors)
126
- assert !@errors.errors.empty?
127
- end
128
-
129
- should "be invalid if run list is empty" do
130
- @config.validation_key_path = nil
131
- @config.validate(@errors)
132
- assert !@errors.errors.empty?
133
- end
134
- end
135
- end
136
66
  end
137
67
 
138
68
  context "verifying binary" do
@@ -143,7 +73,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
143
73
 
144
74
  should "verify binary exists" do
145
75
  binary = "foo"
146
- @ssh.expects(:exec!).with("which #{binary}", anything)
76
+ @ssh.expects(:exec!).with("sudo -i which #{binary}", anything)
147
77
  @action.verify_binary(binary)
148
78
  end
149
79
  end
@@ -152,8 +82,8 @@ class ChefProvisionerTest < Test::Unit::TestCase
152
82
  should "create and chown the folder to the ssh user" do
153
83
  ssh_seq = sequence("ssh_seq")
154
84
  ssh = mock("ssh")
155
- ssh.expects(:exec!).with("sudo mkdir -p #{@env.config.chef.provisioning_path}").once.in_sequence(ssh_seq)
156
- ssh.expects(:exec!).with("sudo chown #{@env.config.ssh.username} #{@env.config.chef.provisioning_path}").once.in_sequence(ssh_seq)
85
+ ssh.expects(:exec!).with("sudo mkdir -p #{@config.provisioning_path}").once.in_sequence(ssh_seq)
86
+ ssh.expects(:exec!).with("sudo chown #{@env.config.ssh.username} #{@config.provisioning_path}").once.in_sequence(ssh_seq)
157
87
  @vm.ssh.expects(:execute).yields(ssh)
158
88
  @action.chown_provisioning_folder
159
89
  end
@@ -174,7 +104,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
174
104
  string_io = mock("string_io")
175
105
  Vagrant::Util::TemplateRenderer.expects(:render).with(@template, anything).returns(template_data)
176
106
  StringIO.expects(:new).with(template_data).returns(string_io)
177
- File.expects(:join).with(@env.config.chef.provisioning_path, @filename).once.returns("bar")
107
+ File.expects(:join).with(@config.provisioning_path, @filename).once.returns("bar")
178
108
  @vm.ssh.expects(:upload!).with(string_io, "bar")
179
109
 
180
110
  @action.setup_config(@template, @filename, {})
@@ -183,7 +113,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
183
113
  should "provide log level by default" do
184
114
  Vagrant::Util::TemplateRenderer.expects(:render).returns("foo").with() do |template, vars|
185
115
  assert vars.has_key?(:log_level)
186
- assert_equal @env.config.chef.log_level.to_sym, vars[:log_level]
116
+ assert_equal @config.log_level.to_sym, vars[:log_level]
187
117
  true
188
118
  end
189
119
 
@@ -221,7 +151,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
221
151
  end
222
152
 
223
153
  should "merge in the extra json specified in the config" do
224
- @env.config.chef.json = { :foo => "BAR" }
154
+ @config.json = { :foo => "BAR" }
225
155
  assert_json do |data|
226
156
  assert_equal "BAR", data["foo"]
227
157
  end
@@ -241,7 +171,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
241
171
 
242
172
  should "upload a StringIO to dna.json" do
243
173
  StringIO.expects(:new).with(anything).returns("bar")
244
- File.expects(:join).with(@env.config.chef.provisioning_path, "dna.json").once.returns("baz")
174
+ File.expects(:join).with(@config.provisioning_path, "dna.json").once.returns("baz")
245
175
  @vm.ssh.expects(:upload!).with("bar", "baz").once
246
176
  @action.setup_json
247
177
  end