machines 0.5.4 → 0.5.6

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 (93) hide show
  1. data/.yardopts +7 -1
  2. data/CHANGELOG.md +16 -4
  3. data/INSTALL.md +3 -0
  4. data/LICENSE +1 -2
  5. data/README.md +47 -28
  6. data/Rakefile +0 -8
  7. data/TODO.md +66 -59
  8. data/bin/machines +1 -2
  9. data/lib/machines.rb +16 -1
  10. data/lib/machines/app_settings.rb +1 -1
  11. data/lib/machines/cloud_machine.rb +1 -1
  12. data/lib/machines/command.rb +0 -2
  13. data/lib/machines/commandline.rb +23 -29
  14. data/lib/machines/commands/checks.rb +67 -0
  15. data/lib/machines/commands/configuration.rb +50 -0
  16. data/lib/machines/commands/database.rb +18 -0
  17. data/lib/machines/commands/file_operations.rb +105 -0
  18. data/lib/machines/commands/installation.rb +184 -0
  19. data/lib/machines/commands/questions.rb +16 -0
  20. data/lib/machines/commands/services.rb +26 -0
  21. data/lib/machines/core.rb +55 -25
  22. data/lib/machines/logger.rb +0 -2
  23. data/lib/machines/named_buffer.rb +7 -6
  24. data/lib/machines/version.rb +1 -1
  25. data/lib/packages/awstats.rb +2 -2
  26. data/lib/packages/docky.rb +0 -1
  27. data/lib/packages/dwm.rb +5 -0
  28. data/lib/packages/nginx_logrotate.rb +2 -2
  29. data/lib/packages/timezone.rb +2 -4
  30. data/lib/template/Machinesfile +2 -1
  31. data/lib/template/config.yml +3 -0
  32. data/spec/lib/machines/app_settings_spec.rb +13 -12
  33. data/spec/lib/machines/cloud_machine_spec.rb +9 -8
  34. data/spec/lib/machines/commandline_spec.rb +69 -90
  35. data/spec/lib/machines/{checks_spec.rb → commands/checks_spec.rb} +1 -1
  36. data/spec/lib/machines/{configuration_spec.rb → commands/configuration_spec.rb} +2 -3
  37. data/spec/lib/machines/{database_spec.rb → commands/database_spec.rb} +4 -10
  38. data/spec/lib/machines/{file_operations_spec.rb → commands/file_operations_spec.rb} +3 -7
  39. data/spec/lib/machines/{installation_spec.rb → commands/installation_spec.rb} +10 -4
  40. data/spec/lib/machines/{questions_spec.rb → commands/questions_spec.rb} +1 -3
  41. data/spec/lib/machines/{services_spec.rb → commands/services_spec.rb} +1 -4
  42. data/spec/lib/machines/core_spec.rb +81 -65
  43. data/spec/lib/packages/abiword_spec.rb +1 -5
  44. data/spec/lib/packages/amazon_mp3_spec.rb +0 -4
  45. data/spec/lib/packages/awstats_spec.rb +3 -4
  46. data/spec/lib/packages/base_spec.rb +0 -1
  47. data/spec/lib/packages/chrome_spec.rb +0 -4
  48. data/spec/lib/packages/cruisecontrol_spec.rb +1 -2
  49. data/spec/lib/packages/dependencies_spec.rb +1 -2
  50. data/spec/lib/packages/docky_spec.rb +0 -4
  51. data/spec/lib/packages/dotfiles_spec.rb +5 -4
  52. data/spec/lib/packages/dwm_spec.rb +23 -0
  53. data/spec/lib/packages/file_roller_spec.rb +1 -5
  54. data/spec/lib/packages/firefox_spec.rb +0 -4
  55. data/spec/lib/packages/gedit_spec.rb +1 -5
  56. data/spec/lib/packages/git_spec.rb +0 -4
  57. data/spec/lib/packages/gmate_spec.rb +1 -5
  58. data/spec/lib/packages/gnome_spec.rb +0 -4
  59. data/spec/lib/packages/gnumeric_spec.rb +1 -5
  60. data/spec/lib/packages/hosts_spec.rb +0 -1
  61. data/spec/lib/packages/load_machines_spec.rb +16 -15
  62. data/spec/lib/packages/monit_spec.rb +0 -1
  63. data/spec/lib/packages/mysql_spec.rb +1 -3
  64. data/spec/lib/packages/nginx_logrotate_spec.rb +17 -18
  65. data/spec/lib/packages/nginx_spec.rb +0 -1
  66. data/spec/lib/packages/openbox_spec.rb +0 -4
  67. data/spec/lib/packages/passenger_nginx_spec.rb +0 -1
  68. data/spec/lib/packages/passenger_spec.rb +0 -1
  69. data/spec/lib/packages/postfix_spec.rb +1 -5
  70. data/spec/lib/packages/questions_spec.rb +3 -4
  71. data/spec/lib/packages/rbenv_spec.rb +1 -4
  72. data/spec/lib/packages/rvm_spec.rb +1 -4
  73. data/spec/lib/packages/save_machines_spec.rb +0 -1
  74. data/spec/lib/packages/slim_spec.rb +1 -2
  75. data/spec/lib/packages/sqlserver_spec.rb +0 -4
  76. data/spec/lib/packages/timezone_spec.rb +2 -3
  77. data/spec/lib/packages/unison_spec.rb +1 -2
  78. data/spec/lib/packages/virtualbox_guest_spec.rb +0 -4
  79. data/spec/lib/packages/virtualbox_spec.rb +1 -2
  80. data/spec/lib/packages/webapps_spec.rb +1 -3
  81. data/spec/spec_helper.rb +59 -61
  82. data/spec/support/minitest.rb +4 -62
  83. metadata +27 -28
  84. data/lib/machines/base.rb +0 -13
  85. data/lib/machines/checks.rb +0 -63
  86. data/lib/machines/configuration.rb +0 -49
  87. data/lib/machines/database.rb +0 -17
  88. data/lib/machines/file_operations.rb +0 -104
  89. data/lib/machines/installation.rb +0 -171
  90. data/lib/machines/machinesfile.rb +0 -25
  91. data/lib/machines/questions.rb +0 -15
  92. data/lib/machines/services.rb +0 -24
  93. data/spec/lib/machines/machinesfile_spec.rb +0 -34
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Checks' do
3
+ describe Commands::Checks do
4
4
  describe 'echo_result' do
5
5
  it do
6
6
  echo_result.must_equal '&& echo CHECK PASSED || echo CHECK FAILED'
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Configuration' do
4
- include Machines::Core
5
- include Machines::Configuration
3
+ describe Commands::Configuration do
6
4
 
7
5
  describe 'add_user' do
8
6
  it do
@@ -20,6 +18,7 @@ describe 'Configuration' do
20
18
 
21
19
  describe 'add' do
22
20
  it 'add an existing user to a group' do
21
+ stubs(:required_options)
23
22
  command = add :user => 'phil', :to => 'group'
24
23
  command.command.must_equal 'usermod -a -G group phil'
25
24
  end
@@ -1,12 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Database' do
4
- include Machines::Core
5
- include Machines::Configuration
6
- include Machines::Database
7
- include Machines::AppSettings
8
- include Machines::FileOperations
9
-
3
+ describe Commands::Database do
10
4
  describe 'write_database_yml' do
11
5
  before do
12
6
  $conf.environment = 'staging'
@@ -15,7 +9,7 @@ describe 'Database' do
15
9
  end
16
10
 
17
11
  it 'supplies correct parameters' do
18
- file = write_database_yml AppBuilder.new(:name => 'app', :password => 'password', :path => 'path')
12
+ file = write_database_yml AppSettings::AppBuilder.new(:name => 'app', :password => 'password', :path => 'path')
19
13
  file.local.read.must_equal <<-EOF
20
14
  ---
21
15
  staging:
@@ -29,12 +23,12 @@ EOF
29
23
  end
30
24
 
31
25
  it 'writes file to specified path' do
32
- file = write_database_yml AppBuilder.new(:name => 'app', :password => 'password', :path => 'path')
26
+ file = write_database_yml AppSettings::AppBuilder.new(:name => 'app', :password => 'password', :path => 'path')
33
27
  file.remote.must_equal 'path/shared/config/database.yml'
34
28
  end
35
29
 
36
30
  it 'overrides database name when supplied' do
37
- file = write_database_yml AppBuilder.new(:name => 'app', :password => 'password', :username => 'phil', :database => 'myapp', :path => 'path')
31
+ file = write_database_yml AppSettings::AppBuilder.new(:name => 'app', :password => 'password', :username => 'phil', :database => 'myapp', :path => 'path')
38
32
  file.local.read.must_equal <<-EOF
39
33
  ---
40
34
  staging:
@@ -1,9 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'FileOperations' do
4
- include Machines::FileOperations
5
- include Machines::Core
6
-
3
+ describe Commands::FileOperations do
7
4
  describe 'append' do
8
5
  it 'escapes backslashes (\\)' do
9
6
  subject = append '\\', :to => 'file'
@@ -62,11 +59,9 @@ describe 'FileOperations' do
62
59
  end
63
60
 
64
61
  describe 'create_from' do
65
- include Machines::AppSettings
66
-
67
62
  it 'loads ERB template, applies settings and writes to remote machine' do
68
63
  File.expects(:read).with('erb_path').returns('<%= method_on_binding %>')
69
- app_builder = AppBuilder.new(:method_on_binding => 'result')
64
+ app_builder = AppSettings::AppBuilder.new(:method_on_binding => 'result')
70
65
  expects(:write).with('result', {:settings => app_builder, :to => 'file', :name => 'erb_path'})
71
66
  create_from('erb_path', :settings => app_builder, :to => 'file')
72
67
  end
@@ -107,6 +102,7 @@ describe 'FileOperations' do
107
102
  end
108
103
 
109
104
  describe 'replace' do
105
+ before { stubs(:required_options) }
110
106
  subject { replace('something', :with => 'some/path', :in => 'file') }
111
107
  it { subject.command.must_equal "sed -i \"s/something/some\\/path/\" file" }
112
108
  it { lambda{replace('something')}.must_raise ArgumentError }
@@ -1,9 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Installation' do
4
- include Machines::Core
5
- include Machines::Installation
6
- include Machines::Configuration
3
+ describe Commands::Installation do
7
4
 
8
5
  describe 'add_ppa' do
9
6
  it 'adds a ppa' do
@@ -166,6 +163,15 @@ describe 'Installation' do
166
163
  'apt-get -q -y install package2'
167
164
  ]
168
165
  end
166
+
167
+ it 'download and run make clean install' do
168
+ subject = install 'http://some.url/package_name.tar.gz', make: true
169
+ subject.map(&:command).join("\n").must_equal [
170
+ 'cd /tmp && wget http://some.url/package_name.tar.gz && tar -zxf package_name.tar.gz && rm package_name.tar.gz && cd -',
171
+ 'mv -f /tmp/package_name /usr/local/src',
172
+ 'cd /usr/local/src/package_name && make clean install'
173
+ ].join("\n")
174
+ end
169
175
  end
170
176
 
171
177
  describe 'uninstall' do
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Questions' do
4
- include Machines::Questions
5
-
3
+ describe Machines::Commands::Questions do
6
4
  describe 'enter_password' do
7
5
  before(:each) do
8
6
  stubs(:ask).returns 'pa55word'
@@ -1,9 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Services' do
4
- include Machines::Core
5
- include Machines::FileOperations
6
- include Machines::Services
3
+ describe Commands::Services do
7
4
 
8
5
  describe 'restart' do
9
6
  subject { restart 'daemon' }
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Machines::Core do
4
- include Machines::Core
5
- include Machines::FileOperations
3
+ describe Core do
4
+
5
+ subject { Core.new }
6
6
 
7
7
  before do
8
8
  @command1 = Machines::Command.new('command 1', 'check 1')
@@ -12,28 +12,54 @@ describe Machines::Core do
12
12
  describe 'generate_password' do
13
13
  it 'generates a random password' do
14
14
  WEBrick::Utils.stubs(:random_string).with(20).returns '01234567890123456789'
15
- generate_password.must_equal '01234567890123456789'
15
+ subject.generate_password.must_equal '01234567890123456789'
16
+ end
17
+ end
18
+
19
+ describe 'package' do
20
+ it 'raises specific error when failing to load Machinesfile' do
21
+ File.expects(:read).never
22
+ lambda{ subject.package 'Machinesfile' }.must_raise LoadError, /Cannot find Machinesfile/
23
+ end
24
+
25
+ it 'loads custom package when it exists' do
26
+ custom_package = "packages/custom_package.rb"
27
+ FileUtils.mkdir_p File.dirname(custom_package)
28
+ FileUtils.touch custom_package
29
+ subject.package :custom_package
30
+ end
31
+
32
+ it 'loads built-in package when no custom package' do
33
+ builtin_package = "#{$conf.application_dir}/packages/builtin_package.rb"
34
+ FileUtils.mkdir_p File.dirname(builtin_package)
35
+ FileUtils.touch builtin_package
36
+ subject.package :builtin_package
37
+ end
38
+
39
+ it 'raises when no custom and no built-in package' do
40
+ File.expects(:read).never
41
+ lambda { subject.package :builtin_package}.must_raise LoadError, /Cannot find .* package builtin_package/
16
42
  end
17
43
  end
18
44
 
19
45
  describe 'task' do
20
46
  it 'yields' do
21
47
  yielded = false
22
- task :name do
48
+ subject.task :name do
23
49
  yielded = true
24
50
  end
25
51
  yielded.must_equal true
26
52
  end
27
53
 
28
54
  it 'logs the task' do
29
- task :name, 'description' do
55
+ subject.task :name, 'description' do
30
56
  end
31
57
  $conf.commands.first.info.must_equal "TASK name - description"
32
58
  end
33
59
 
34
60
  it 'stores task' do
35
61
  block = Proc.new {}
36
- task :name, 'description', &block
62
+ subject.task :name, 'description', &block
37
63
  $conf.tasks.must_equal :name => {:description => 'description', :block => block}
38
64
  end
39
65
 
@@ -42,7 +68,7 @@ describe Machines::Core do
42
68
  block = Proc.new { block_run_count += 1 }
43
69
  $conf.tasks[:task1] = {:block => block}
44
70
  $conf.tasks[:task2] = {:block => block}
45
- task [:task1, 'task2']
71
+ subject.task [:task1, 'task2']
46
72
  block_run_count.must_equal 2
47
73
  end
48
74
 
@@ -50,7 +76,7 @@ describe Machines::Core do
50
76
  block_run = false
51
77
  block = Proc.new { block_run = true }
52
78
  $conf.tasks[:task] = {:block => block}
53
- task :task
79
+ subject.task :task
54
80
  block_run.must_equal true
55
81
  end
56
82
 
@@ -62,8 +88,8 @@ describe Machines::Core do
62
88
 
63
89
  describe 'exists' do
64
90
  before(:each) do
65
- store_task :dependent_task, nil
66
- task :name, nil, :if => :dependent_task, &@block
91
+ subject.store_task :dependent_task, nil
92
+ subject.task :name, nil, :if => :dependent_task, &@block
67
93
  end
68
94
 
69
95
  it { @yielded.must_equal true }
@@ -73,7 +99,7 @@ describe Machines::Core do
73
99
  end
74
100
 
75
101
  describe 'does not exist' do
76
- before(:each) { task :name, nil, :if => :dependent_task, &@block }
102
+ before(:each) { subject.task :name, nil, :if => :dependent_task, &@block }
77
103
  it { @yielded.must_equal false }
78
104
  it 'task not stored' do
79
105
  $conf.tasks.wont_include :name
@@ -89,9 +115,9 @@ describe Machines::Core do
89
115
 
90
116
  describe 'all exist' do
91
117
  before(:each) do
92
- store_task :dependent_task, nil
93
- store_task :another_dependent, nil
94
- task :name, nil, :if => [:dependent_task, :another_dependent], &@block
118
+ subject.store_task :dependent_task, nil
119
+ subject.store_task :another_dependent, nil
120
+ subject.task :name, nil, :if => [:dependent_task, :another_dependent], &@block
95
121
  end
96
122
 
97
123
  it { @yielded.must_equal true }
@@ -102,8 +128,8 @@ describe Machines::Core do
102
128
 
103
129
  describe 'all but one exist' do
104
130
  before(:each) do
105
- store_task :another_dependent, nil
106
- task :name, nil, :if => [:dependent_task, :another_dependent], &@block
131
+ subject.store_task :another_dependent, nil
132
+ subject.task :name, nil, :if => [:dependent_task, :another_dependent], &@block
107
133
  end
108
134
 
109
135
  it { @yielded.must_equal false }
@@ -114,30 +140,20 @@ describe Machines::Core do
114
140
  end
115
141
  end
116
142
 
117
- describe 'list_tasks' do
118
- it 'displays a list of tasks' do
119
- task :name, 'description', &Proc.new {}
120
- task :another, 'another description', &Proc.new {}
121
- lambda { list_tasks }.must_output ' name description
122
- another another description
123
- '
124
- end
125
- end
126
-
127
143
  describe 'only' do
128
144
  it 'yields when matched' do
129
- expects(:matched).with('options').returns true
145
+ subject.expects(:matched).with('options').returns true
130
146
  yielded = false
131
- only 'options' do
147
+ subject.only 'options' do
132
148
  yielded = true
133
149
  end
134
150
  yielded.must_equal true
135
151
  end
136
152
 
137
153
  it 'does not yield when not matched' do
138
- expects(:matched).with('options').returns false
154
+ subject.expects(:matched).with('options').returns false
139
155
  yielded = false
140
- only 'options' do
156
+ subject.only 'options' do
141
157
  yielded = true
142
158
  end
143
159
  yielded.must_equal false
@@ -146,7 +162,7 @@ describe Machines::Core do
146
162
  it 'yields when symbol matches string' do
147
163
  $conf.environment = 'development'
148
164
  yielded = false
149
- only :environment => :development do
165
+ subject.only :environment => :development do
150
166
  yielded = true
151
167
  end
152
168
  yielded.must_equal true
@@ -155,18 +171,18 @@ describe Machines::Core do
155
171
 
156
172
  describe 'except' do
157
173
  it 'does not yield when matched' do
158
- expects(:matched).with('options').returns true
174
+ subject.expects(:matched).with('options').returns true
159
175
  yielded = false
160
- except 'options' do
176
+ subject.except 'options' do
161
177
  yielded = true
162
178
  end
163
179
  yielded.must_equal false
164
180
  end
165
181
 
166
182
  it 'yields when not matched' do
167
- expects(:matched).with('options').returns false
183
+ subject.expects(:matched).with('options').returns false
168
184
  yielded = false
169
- except 'options' do
185
+ subject.except 'options' do
170
186
  yielded = true
171
187
  end
172
188
  yielded.must_equal true
@@ -179,9 +195,9 @@ describe Machines::Core do
179
195
  $conf.string_param = 'matched'
180
196
  end
181
197
 
182
- it { matched(:string_param => :matched).must_equal true }
183
- it { matched(:string_param => 'matched').must_equal true }
184
- it { matched(:string_param => :unmatched).wont_equal true }
198
+ it { subject.matched(:string_param => :matched).must_equal true }
199
+ it { subject.matched(:string_param => 'matched').must_equal true }
200
+ it { subject.matched(:string_param => :unmatched).wont_equal true }
185
201
  end
186
202
 
187
203
  describe '$conf values are arrays' do
@@ -190,23 +206,23 @@ describe Machines::Core do
190
206
  end
191
207
 
192
208
  describe 'options values are arrays of symbols' do
193
- it { matched({:params_array => [:matched]}).must_equal true }
194
- it { matched({:params_array => [:unmatched]}).wont_equal true }
209
+ it { subject.matched({:params_array => [:matched]}).must_equal true }
210
+ it { subject.matched({:params_array => [:unmatched]}).wont_equal true }
195
211
  end
196
212
 
197
213
  describe 'options values are arrays of strings' do
198
- it { matched({'params_array' => ['matched']}).must_equal true }
199
- it { matched({'params_array' => ['unmatched']}).wont_equal true }
214
+ it { subject.matched({'params_array' => ['matched']}).must_equal true }
215
+ it { subject.matched({'params_array' => ['unmatched']}).wont_equal true }
200
216
  end
201
217
 
202
218
  describe 'options values are symbols' do
203
- it { matched({:params_array => :matched}).must_equal true }
204
- it { matched({:params_array => :unmatched}).wont_equal true }
219
+ it { subject.matched({:params_array => :matched}).must_equal true }
220
+ it { subject.matched({:params_array => :unmatched}).wont_equal true }
205
221
  end
206
222
 
207
223
  describe 'options values are strings' do
208
- it { matched({:params_array => 'matched'}).must_equal true }
209
- it { matched({:params_array => 'unmatched'}).wont_equal true }
224
+ it { subject.matched({:params_array => 'matched'}).must_equal true }
225
+ it { subject.matched({:params_array => 'unmatched'}).wont_equal true }
210
226
  end
211
227
  end
212
228
 
@@ -216,37 +232,37 @@ describe Machines::Core do
216
232
  end
217
233
 
218
234
  describe 'options values are arrays' do
219
- it { matched({:single_param => [:matched]}).must_equal true }
220
- it { matched({:single_param => [:unmatched]}).wont_equal true }
235
+ it { subject.matched({:single_param => [:matched]}).must_equal true }
236
+ it { subject.matched({:single_param => [:unmatched]}).wont_equal true }
221
237
  end
222
238
 
223
239
  describe 'options values are symbols' do
224
- it { matched({:single_param => :matched}).must_equal true }
225
- it { matched({:single_param => :unmatched}).wont_equal true }
240
+ it { subject.matched({:single_param => :matched}).must_equal true }
241
+ it { subject.matched({:single_param => :unmatched}).wont_equal true }
226
242
  end
227
243
  end
228
244
  end
229
245
 
230
246
  describe 'run' do
231
247
  it 'adds a command to the commands array' do
232
- run @command1
248
+ subject.run @command1
233
249
  $conf.commands.must_equal [@command1]
234
250
  end
235
251
 
236
252
  it 'appends several commands' do
237
- run @command1
238
- run @command2
253
+ subject.run @command1
254
+ subject.run @command2
239
255
  $conf.commands.must_equal [@command1, @command2]
240
256
  end
241
257
 
242
258
  it 'appends several commands in a single call' do
243
- run @command1, @command2
259
+ subject.run @command1, @command2
244
260
  $conf.commands.must_equal [@command1, @command2]
245
261
  end
246
262
 
247
263
  describe 'when commands are two strings' do
248
264
  it 'creates a Command' do
249
- run 'command', 'check'
265
+ subject.run 'command', 'check'
250
266
  $conf.commands.first.command.must_equal 'command'
251
267
  $conf.commands.first.check.must_equal 'check'
252
268
  end
@@ -257,12 +273,12 @@ describe Machines::Core do
257
273
  it 'wraps a command in a sudo with password call' do
258
274
  $conf.password = 'password'
259
275
  @command1.expects(:use_sudo)
260
- sudo @command1
276
+ subject.sudo @command1
261
277
  end
262
278
 
263
279
  describe 'when commands are two strings' do
264
280
  it 'creates a Command' do
265
- sudo 'command', 'check'
281
+ subject.sudo 'command', 'check'
266
282
  $conf.commands.first.command.must_equal 'command'
267
283
  $conf.commands.first.check.must_equal 'check'
268
284
  end
@@ -270,15 +286,15 @@ describe Machines::Core do
270
286
  end
271
287
 
272
288
  describe 'upload' do
273
- subject { upload 'source', 'dest' }
274
- it { subject.local.must_equal 'source' }
275
- it { subject.remote.must_equal 'dest' }
289
+ let(:upload) { subject.upload 'source', 'dest' }
290
+ it { upload.local.must_equal 'source' }
291
+ it { upload.remote.must_equal 'dest' }
276
292
  end
277
293
 
278
294
  describe 'sudo upload' do
279
295
  it 'modifies Upload to send it to a temp file and sudos to copy it to destination' do
280
296
  File.stubs(:directory?).returns false
281
- sudo upload 'source', 'dest'
297
+ subject.sudo subject.upload 'source', 'dest'
282
298
 
283
299
  $conf.commands.map(&:command).must_equal [nil, "cp -rf /tmp/dest dest", "rm -rf /tmp/dest"]
284
300
  $conf.commands.map(&:check).must_equal [
@@ -290,18 +306,18 @@ describe Machines::Core do
290
306
 
291
307
  it 'adds /. to the end of folder paths' do
292
308
  File.stubs(:directory?).with('source').returns true
293
- sudo upload 'source', 'dest'
309
+ subject.sudo subject.upload 'source', 'dest'
294
310
  $conf.commands.map(&:command).must_equal [nil, "cp -rf /tmp/dest/. dest", "rm -rf /tmp/dest"]
295
311
  end
296
312
  end
297
313
 
298
314
  describe 'required_options' do
299
315
  it 'does not raise when option exists' do
300
- required_options({:required => :option}, [:required])
316
+ subject.required_options({:required => :option}, [:required])
301
317
  end
302
318
 
303
319
  it 'raises when option does not exist' do
304
- lambda{required_options({}, [:required])}.must_raise(ArgumentError)
320
+ lambda{ subject.required_options({}, [:required]) }.must_raise(ArgumentError)
305
321
  end
306
322
  end
307
323
  end