test-kitchen 1.3.1 → 1.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.cane +2 -0
  3. data/.gitignore +4 -0
  4. data/CHANGELOG.md +45 -0
  5. data/Rakefile +15 -0
  6. data/features/kitchen_action_commands.feature +12 -9
  7. data/features/kitchen_defaults.feature +38 -0
  8. data/features/kitchen_init_command.feature +0 -1
  9. data/features/kitchen_list_command.feature +2 -2
  10. data/features/kitchen_login_command.feature +7 -1
  11. data/features/kitchen_test_command.feature +4 -4
  12. data/lib/kitchen.rb +40 -11
  13. data/lib/kitchen/cli.rb +38 -22
  14. data/lib/kitchen/command/list.rb +5 -2
  15. data/lib/kitchen/config.rb +45 -18
  16. data/lib/kitchen/configurable.rb +137 -1
  17. data/lib/kitchen/data_munger.rb +248 -17
  18. data/lib/kitchen/driver.rb +1 -1
  19. data/lib/kitchen/driver/base.rb +1 -83
  20. data/lib/kitchen/driver/dummy.rb +0 -5
  21. data/lib/kitchen/driver/ssh_base.rb +177 -22
  22. data/lib/kitchen/instance.rb +140 -20
  23. data/lib/kitchen/logger.rb +43 -8
  24. data/lib/kitchen/login_command.rb +14 -5
  25. data/lib/kitchen/platform.rb +19 -0
  26. data/lib/kitchen/provisioner.rb +5 -3
  27. data/lib/kitchen/provisioner/base.rb +46 -48
  28. data/lib/kitchen/provisioner/chef/common_sandbox.rb +322 -0
  29. data/lib/kitchen/provisioner/chef_base.rb +179 -286
  30. data/lib/kitchen/provisioner/chef_solo.rb +11 -5
  31. data/lib/kitchen/provisioner/chef_zero.rb +108 -94
  32. data/lib/kitchen/provisioner/dummy.rb +47 -0
  33. data/lib/kitchen/provisioner/shell.rb +45 -12
  34. data/lib/kitchen/rake_tasks.rb +1 -1
  35. data/lib/kitchen/ssh.rb +1 -1
  36. data/lib/kitchen/thor_tasks.rb +1 -1
  37. data/lib/kitchen/transport.rb +54 -0
  38. data/lib/kitchen/transport/base.rb +146 -0
  39. data/lib/kitchen/transport/dummy.rb +75 -0
  40. data/lib/kitchen/transport/ssh.rb +325 -0
  41. data/lib/kitchen/transport/winrm.rb +508 -0
  42. data/lib/kitchen/transport/winrm/command_executor.rb +188 -0
  43. data/lib/kitchen/transport/winrm/file_transporter.rb +454 -0
  44. data/lib/kitchen/transport/winrm/logging.rb +50 -0
  45. data/lib/kitchen/transport/winrm/template.rb +74 -0
  46. data/lib/kitchen/transport/winrm/tmp_zip.rb +187 -0
  47. data/lib/kitchen/verifier.rb +55 -0
  48. data/lib/kitchen/verifier/base.rb +191 -0
  49. data/lib/kitchen/verifier/busser.rb +266 -0
  50. data/lib/kitchen/verifier/dummy.rb +75 -0
  51. data/lib/kitchen/version.rb +1 -1
  52. data/spec/kitchen/cli_spec.rb +56 -0
  53. data/spec/kitchen/config_spec.rb +61 -20
  54. data/spec/kitchen/configurable_spec.rb +327 -1
  55. data/spec/kitchen/data_munger_spec.rb +777 -14
  56. data/spec/kitchen/driver/base_spec.rb +7 -38
  57. data/spec/kitchen/driver/dummy_spec.rb +0 -29
  58. data/spec/kitchen/driver/ssh_base_spec.rb +580 -236
  59. data/spec/kitchen/driver_spec.rb +1 -0
  60. data/spec/kitchen/instance_spec.rb +383 -83
  61. data/spec/kitchen/login_command_spec.rb +29 -10
  62. data/spec/kitchen/platform_spec.rb +58 -2
  63. data/spec/kitchen/provisioner/base_spec.rb +170 -18
  64. data/spec/kitchen/provisioner/chef_base_spec.rb +454 -104
  65. data/spec/kitchen/provisioner/chef_solo_spec.rb +307 -104
  66. data/spec/kitchen/provisioner/chef_zero_spec.rb +561 -230
  67. data/spec/kitchen/provisioner/dummy_spec.rb +91 -0
  68. data/spec/kitchen/provisioner/shell_spec.rb +158 -56
  69. data/spec/kitchen/provisioner_spec.rb +37 -0
  70. data/spec/kitchen/ssh_spec.rb +19 -19
  71. data/spec/kitchen/transport/base_spec.rb +89 -0
  72. data/spec/kitchen/transport/ssh_spec.rb +1147 -0
  73. data/spec/kitchen/transport/winrm/command_executor_spec.rb +400 -0
  74. data/spec/kitchen/transport/winrm/file_transporter_spec.rb +876 -0
  75. data/spec/kitchen/transport/winrm/logging_spec.rb +92 -0
  76. data/spec/kitchen/transport/winrm/template_spec.rb +51 -0
  77. data/spec/kitchen/transport/winrm/tmp_zip_spec.rb +132 -0
  78. data/spec/kitchen/transport/winrm_spec.rb +1069 -0
  79. data/spec/kitchen/transport_spec.rb +112 -0
  80. data/spec/kitchen/verifier/base_spec.rb +310 -0
  81. data/spec/kitchen/verifier/busser_spec.rb +540 -0
  82. data/spec/kitchen/verifier/dummy_spec.rb +91 -0
  83. data/spec/kitchen/verifier_spec.rb +120 -0
  84. data/spec/kitchen_spec.rb +7 -0
  85. data/spec/spec_helper.rb +8 -0
  86. data/spec/support/powershell_max_size_spec.rb +40 -0
  87. data/support/busser_install_command.ps1 +14 -0
  88. data/support/busser_install_command.sh +15 -0
  89. data/support/check_files.ps1.erb +48 -0
  90. data/support/chef_base_init_command.ps1 +18 -0
  91. data/support/chef_base_init_command.sh +2 -0
  92. data/support/chef_base_install_command.ps1 +76 -0
  93. data/support/chef_base_install_command.sh +137 -0
  94. data/support/chef_zero_prepare_command_legacy.ps1 +9 -0
  95. data/support/chef_zero_prepare_command_legacy.sh +10 -0
  96. data/support/decode_files.ps1.erb +61 -0
  97. data/test-kitchen.gemspec +2 -0
  98. metadata +97 -8
  99. data/lib/kitchen/busser.rb +0 -316
  100. data/spec/kitchen/busser_spec.rb +0 -490
  101. data/support/chef_helpers.sh +0 -16
@@ -0,0 +1,91 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
+ #
5
+ # Copyright (C) 2015, Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require_relative "../../spec_helper"
20
+
21
+ require "logger"
22
+ require "stringio"
23
+
24
+ require "kitchen/provisioner/dummy"
25
+
26
+ describe Kitchen::Provisioner::Dummy do
27
+
28
+ let(:logged_output) { StringIO.new }
29
+ let(:logger) { Logger.new(logged_output) }
30
+ let(:platform) { stub(:os_type => nil, :shell_type => nil) }
31
+ let(:suite) { stub(:name => "fries") }
32
+ let(:state) { Hash.new }
33
+
34
+ let(:config) do
35
+ { :test_base_path => "/basist", :kitchen_root => "/rooty" }
36
+ end
37
+
38
+ let(:instance) do
39
+ stub(
40
+ :name => "coolbeans",
41
+ :to_str => "instance",
42
+ :logger => logger,
43
+ :suite => suite,
44
+ :platform => platform
45
+ )
46
+ end
47
+
48
+ let(:provisioner) do
49
+ Kitchen::Provisioner::Dummy.new(config).finalize_config!(instance)
50
+ end
51
+
52
+ describe "configuration" do
53
+
54
+ it "sets :sleep to 0 by default" do
55
+ provisioner[:sleep].must_equal 0
56
+ end
57
+
58
+ it "sets :random_failure to false by default" do
59
+ provisioner[:random_failure].must_equal false
60
+ end
61
+ end
62
+
63
+ describe "#call" do
64
+
65
+ it "calls sleep if :sleep value is greater than 0" do
66
+ config[:sleep] = 12.5
67
+ provisioner.expects(:sleep).with(12.5).returns(true)
68
+
69
+ provisioner.call(state)
70
+ end
71
+
72
+ it "raises ActionFailed if :fail is set" do
73
+ config[:fail] = true
74
+
75
+ proc { provisioner.call(state) }.must_raise Kitchen::ActionFailed
76
+ end
77
+
78
+ it "randomly raises ActionFailed if :random_failure is set" do
79
+ config[:random_failure] = true
80
+ provisioner.stubs(:randomly_fail?).returns(true)
81
+
82
+ proc { provisioner.call(state) }.must_raise Kitchen::ActionFailed
83
+ end
84
+
85
+ it "logs a converge event to INFO" do
86
+ provisioner.call(state)
87
+
88
+ logged_output.string.must_match(/^.+ INFO .+ \[Dummy\] Converge on .+$/)
89
+ end
90
+ end
91
+ end
@@ -25,17 +25,20 @@ describe Kitchen::Provisioner::Shell do
25
25
 
26
26
  let(:logged_output) { StringIO.new }
27
27
  let(:logger) { Logger.new(logged_output) }
28
+ let(:platform) { stub(:os_type => nil, :shell_type => nil) }
29
+ let(:suite) { stub(:name => "fries") }
28
30
 
29
31
  let(:config) do
30
32
  { :test_base_path => "/basist", :kitchen_root => "/rooty" }
31
33
  end
32
34
 
33
- let(:suite) do
34
- stub(:name => "fries")
35
- end
36
-
37
35
  let(:instance) do
38
- stub(:name => "coolbeans", :logger => logger, :suite => suite)
36
+ stub(
37
+ :name => "coolbeans",
38
+ :logger => logger,
39
+ :suite => suite,
40
+ :platform => platform
41
+ )
39
42
  end
40
43
 
41
44
  let(:provisioner) do
@@ -48,8 +51,22 @@ describe Kitchen::Provisioner::Shell do
48
51
 
49
52
  describe "configuration" do
50
53
 
51
- it ":script uses calculate_path and is expanded" do
52
- provisioner[:script].must_equal "/rooty/<calculated>/bootstrap.sh"
54
+ describe "for bourne shells" do
55
+
56
+ before { platform.stubs(:shell_type).returns("bourne") }
57
+
58
+ it ":script uses calculate_path and is expanded" do
59
+ provisioner[:script].must_equal "/rooty/<calculated>/bootstrap.sh"
60
+ end
61
+ end
62
+
63
+ describe "for powershell shells" do
64
+
65
+ before { platform.stubs(:shell_type).returns("powershell") }
66
+
67
+ it ":script uses calculate_path and is expanded" do
68
+ provisioner[:script].must_equal "/rooty/<calculated>/bootstrap.ps1"
69
+ end
53
70
  end
54
71
 
55
72
  it ":data_path uses calculate_path and is expanded" do
@@ -61,36 +78,69 @@ describe Kitchen::Provisioner::Shell do
61
78
 
62
79
  let(:cmd) { provisioner.init_command }
63
80
 
64
- it "uses bourne shell" do
65
- cmd.must_match(/\Ash -c '$/)
66
- cmd.must_match(/'\Z/)
67
- end
81
+ describe "for bourne shells" do
68
82
 
69
- it "uses sudo for rm when configured" do
70
- config[:sudo] = true
83
+ before { platform.stubs(:shell_type).returns("bourne") }
71
84
 
72
- cmd.must_match regexify("sudo -E rm -rf ", :partial_line)
73
- end
85
+ it "uses bourne shell" do
86
+ cmd.must_match(/\Ash -c '$/)
87
+ cmd.must_match(/'\Z/)
88
+ end
74
89
 
75
- it "does not use sudo for rm when configured" do
76
- config[:sudo] = false
90
+ it "uses sudo for rm when configured" do
91
+ config[:sudo] = true
77
92
 
78
- provisioner.init_command.
79
- must_match regexify("rm -rf ", :partial_line)
80
- provisioner.init_command.
81
- wont_match regexify("sudo -E rm -rf ", :partial_line)
82
- end
93
+ cmd.must_match regexify("sudo -E rm -rf ", :partial_line)
94
+ end
83
95
 
84
- it "removes the data directory" do
85
- config[:root_path] = "/route"
96
+ it "does not use sudo for rm when configured" do
97
+ config[:sudo] = false
98
+
99
+ provisioner.init_command.
100
+ must_match regexify("rm -rf ", :partial_line)
101
+ provisioner.init_command.
102
+ wont_match regexify("sudo -E rm -rf ", :partial_line)
103
+ end
86
104
 
87
- cmd.must_match %r{rm -rf\b.*\s+/route/data\s+}
105
+ it "removes the data directory" do
106
+ config[:root_path] = "/route"
107
+
108
+ cmd.must_match %r{rm -rf\b.*\s+/route/data\s+}
109
+ end
110
+
111
+ it "creates :root_path directory" do
112
+ config[:root_path] = "/root/path"
113
+
114
+ cmd.must_match regexify("mkdir -p /root/path", :partial_line)
115
+ end
88
116
  end
89
117
 
90
- it "creates :root_path directory" do
91
- config[:root_path] = "/root/path"
118
+ describe "for powershell shells on windows os types" do
119
+
120
+ before do
121
+ platform.stubs(:os_type).returns("windows")
122
+ platform.stubs(:shell_type).returns("powershell")
123
+ end
124
+
125
+ it "removes the data directory" do
126
+ config[:root_path] = "\\route"
127
+
128
+ cmd.must_match regexify(Kitchen::Util.outdent!(<<-POWERSHELL).chomp)
129
+ if (Test-Path "\\route\\data") {
130
+ Remove-Item "\\route\\data" -Recurse -Force
131
+ }
132
+ POWERSHELL
133
+ end
134
+
135
+ it "creates the :root_path directory" do
136
+ config[:root_path] = "\\route"
92
137
 
93
- cmd.must_match regexify("mkdir -p /root/path", :partial_line)
138
+ cmd.must_match regexify(Kitchen::Util.outdent!(<<-POWERSHELL).chomp)
139
+ if (-Not (Test-Path "\\route")) {
140
+ New-Item "\\route" -ItemType directory | Out-Null
141
+ }
142
+ POWERSHELL
143
+ end
94
144
  end
95
145
  end
96
146
 
@@ -98,24 +148,43 @@ describe Kitchen::Provisioner::Shell do
98
148
 
99
149
  let(:cmd) { provisioner.run_command }
100
150
 
101
- it "uses bourne shell" do
102
- cmd.must_match(/\Ash -c '$/)
103
- cmd.must_match(/'\Z/)
104
- end
151
+ describe "for bourne shells" do
152
+
153
+ before { platform.stubs(:shell_type).returns("bourne") }
154
+
155
+ it "uses bourne shell" do
156
+ cmd.must_match(/\Ash -c '$/)
157
+ cmd.must_match(/'\Z/)
158
+ end
159
+
160
+ it "uses sudo for script when configured" do
161
+ config[:root_path] = "/r"
162
+ config[:sudo] = true
105
163
 
106
- it "uses sudo for script when configured" do
107
- config[:root_path] = "/r"
108
- config[:sudo] = true
164
+ cmd.must_match regexify("sudo -E /r/bootstrap.sh", :partial_line)
165
+ end
109
166
 
110
- cmd.must_match regexify("sudo -E /r/bootstrap.sh", :partial_line)
167
+ it "does not use sudo for script when configured" do
168
+ config[:root_path] = "/r"
169
+ config[:sudo] = false
170
+
171
+ cmd.must_match regexify("/r/bootstrap.sh", :partial_line)
172
+ cmd.wont_match regexify("sudo -E /r/bootstrap.sh", :partial_line)
173
+ end
111
174
  end
112
175
 
113
- it "does not use sudo for script when configured" do
114
- config[:root_path] = "/r"
115
- config[:sudo] = false
176
+ describe "for powershell shells on windows os types" do
177
+
178
+ before do
179
+ platform.stubs(:shell_type).returns("powershell")
180
+ platform.stubs(:os_type).returns("windows")
181
+ end
182
+
183
+ it "invokes the bootstrap.ps1 script" do
184
+ config[:root_path] = "\\r"
116
185
 
117
- cmd.must_match regexify("/r/bootstrap.sh", :partial_line)
118
- cmd.wont_match regexify("sudo -E /r/bootstrap.sh", :partial_line)
186
+ cmd.must_equal %{& "\\r\\bootstrap.ps1"}
187
+ end
119
188
  end
120
189
  end
121
190
 
@@ -213,27 +282,60 @@ describe Kitchen::Provisioner::Shell do
213
282
 
214
283
  before { config[:script] = nil }
215
284
 
216
- it "logs a message on info" do
217
- provisioner.create_sandbox
285
+ describe "for bourne shells" do
218
286
 
219
- logged_output.string.must_match info_line("Preparing script")
220
- end
287
+ before { platform.stubs(:shell_type).returns("bourne") }
221
288
 
222
- it "logs a warning on info" do
223
- provisioner.create_sandbox
289
+ it "logs a message on info" do
290
+ provisioner.create_sandbox
291
+
292
+ logged_output.string.must_match info_line("Preparing script")
293
+ end
224
294
 
225
- logged_output.string.must_match info_line(
226
- "bootstrap.sh not found so Kitchen will run a stubbed script. " \
227
- "Is this intended?")
295
+ it "logs a warning on info" do
296
+ provisioner.create_sandbox
297
+
298
+ logged_output.string.must_match info_line(
299
+ "bootstrap.sh not found so Kitchen will run a stubbed script. " \
300
+ "Is this intended?")
301
+ end
302
+
303
+ it "creates a file in the sandbox directory" do
304
+ provisioner.create_sandbox
305
+
306
+ sandbox_path("bootstrap.sh").file?.must_equal true
307
+ sandbox_path("bootstrap.sh").executable?.must_equal true
308
+ IO.read(sandbox_path("bootstrap.sh")).
309
+ must_match(/NO BOOTSTRAP SCRIPT PRESENT/)
310
+ end
228
311
  end
229
312
 
230
- it "creates a file in the sandbox directory" do
231
- provisioner.create_sandbox
313
+ describe "for powershell shells" do
314
+
315
+ before { platform.stubs(:shell_type).returns("powershell") }
232
316
 
233
- sandbox_path("bootstrap.sh").file?.must_equal true
234
- sandbox_path("bootstrap.sh").executable?.must_equal true
235
- IO.read(sandbox_path("bootstrap.sh")).
236
- must_match(/NO BOOTSTRAP SCRIPT PRESENT/)
317
+ it "logs a message on info" do
318
+ provisioner.create_sandbox
319
+
320
+ logged_output.string.must_match info_line("Preparing script")
321
+ end
322
+
323
+ it "logs a warning on info" do
324
+ provisioner.create_sandbox
325
+
326
+ logged_output.string.must_match info_line(
327
+ "bootstrap.ps1 not found so Kitchen will run a stubbed script. " \
328
+ "Is this intended?")
329
+ end
330
+
331
+ it "creates a file in the sandbox directory" do
332
+ provisioner.create_sandbox
333
+
334
+ sandbox_path("bootstrap.ps1").file?.must_equal true
335
+ sandbox_path("bootstrap.ps1").executable?.must_equal true
336
+ IO.read(sandbox_path("bootstrap.ps1")).
337
+ must_match(/Write-Host "NO BOOTSTRAP SCRIPT PRESENT`n"/)
338
+ end
237
339
  end
238
340
  end
239
341
  end
@@ -18,6 +18,7 @@
18
18
 
19
19
  require_relative "../spec_helper"
20
20
 
21
+ require "kitchen/configurable"
21
22
  require "kitchen/errors"
22
23
  require "kitchen/logging"
23
24
  require "kitchen/provisioner"
@@ -29,6 +30,27 @@ module Kitchen
29
30
 
30
31
  class Coolbeans < Kitchen::Provisioner::Base
31
32
  end
33
+
34
+ class ItDepends < Kitchen::Provisioner::Base
35
+
36
+ attr_reader :verify_call_count
37
+
38
+ def initialize(config = {})
39
+ @verify_call_count = 0
40
+ super
41
+ end
42
+
43
+ def verify_dependencies
44
+ @verify_call_count += 1
45
+ end
46
+ end
47
+
48
+ class UnstableDepends < Kitchen::Provisioner::Base
49
+
50
+ def verify_dependencies
51
+ raise UserError, "Oh noes, you don't have software!"
52
+ end
53
+ end
32
54
  end
33
55
  end
34
56
 
@@ -52,6 +74,21 @@ describe Kitchen::Provisioner do
52
74
  provisioner[:foo].must_equal "bar"
53
75
  end
54
76
 
77
+ it "calls #verify_dependencies on the provisioner object" do
78
+ provisioner = Kitchen::Provisioner.for_plugin("it_depends", {})
79
+
80
+ provisioner.verify_call_count.must_equal 1
81
+ end
82
+
83
+ it "calls #verify_dependencies once per provisioner require" do
84
+ Kitchen::Provisioner.stubs(:require).returns(true, false)
85
+ provisioner1 = Kitchen::Provisioner.for_plugin("it_depends", {})
86
+ provisioner1.verify_call_count.must_equal 1
87
+ provisioner2 = Kitchen::Provisioner.for_plugin("it_depends", {})
88
+
89
+ provisioner2.verify_call_count.must_equal 0
90
+ end
91
+
55
92
  it "raises ClientError if the provisioner could not be required" do
56
93
  Kitchen::Provisioner.stubs(:require).raises(LoadError)
57
94
 
@@ -19,8 +19,8 @@
19
19
  require_relative "../spec_helper"
20
20
 
21
21
  require "net/ssh/test"
22
-
23
22
  require "kitchen/ssh"
23
+ require "tmpdir"
24
24
 
25
25
  # Hack to sort results in `Dir.entries` only within the yielded block, to limit
26
26
  # the "behavior pollution" to other code. This was needed for Net::SCP, as
@@ -406,7 +406,7 @@ describe Kitchen::SSH do
406
406
  end
407
407
 
408
408
  it "logs upload progress to debug" do
409
- remote_base = "/tmp/#{File.basename(@dir)}"
409
+ remote_base = "#{Dir.tmpdir}/#{File.basename(@dir)}"
410
410
 
411
411
  with_sorted_dir_entries do
412
412
  assert_scripted { ssh.upload_path!(@dir, "/tmp/remote") }
@@ -492,84 +492,84 @@ describe Kitchen::SSH do
492
492
  describe "#login_command" do
493
493
 
494
494
  let(:login_command) { ssh.login_command }
495
- let(:cmd) { login_command.cmd_array.join(" ") }
495
+ let(:args) { login_command.arguments.join(" ") }
496
496
 
497
497
  it "returns a LoginCommand" do
498
498
  login_command.must_be_instance_of Kitchen::LoginCommand
499
499
  end
500
500
 
501
501
  it "is an SSH command" do
502
- cmd.must_match %r{^ssh }
503
- cmd.must_match %r{ me@foo$}
502
+ login_command.command.must_equal "ssh"
503
+ args.must_match %r{ me@foo$}
504
504
  end
505
505
 
506
506
  it "sets the UserKnownHostsFile option" do
507
- cmd.must_match regexify(" -o UserKnownHostsFile=/dev/null ")
507
+ args.must_match regexify("-o UserKnownHostsFile=/dev/null ")
508
508
  end
509
509
 
510
510
  it "sets the StrictHostKeyChecking option" do
511
- cmd.must_match regexify(" -o StrictHostKeyChecking=no ")
511
+ args.must_match regexify(" -o StrictHostKeyChecking=no ")
512
512
  end
513
513
 
514
514
  it "won't set IdentitiesOnly option by default" do
515
- cmd.wont_match regexify(" -o IdentitiesOnly=")
515
+ args.wont_match regexify(" -o IdentitiesOnly=")
516
516
  end
517
517
 
518
518
  it "sets the IdentiesOnly option if :keys option is given" do
519
519
  opts[:keys] = ["yep"]
520
520
 
521
- cmd.must_match regexify(" -o IdentitiesOnly=yes ")
521
+ args.must_match regexify(" -o IdentitiesOnly=yes ")
522
522
  end
523
523
 
524
524
  it "sets the LogLevel option to VERBOSE if logger is set to debug" do
525
525
  logger.level = ::Logger::DEBUG
526
526
  opts[:logger] = logger
527
527
 
528
- cmd.must_match regexify(" -o LogLevel=VERBOSE ")
528
+ args.must_match regexify(" -o LogLevel=VERBOSE ")
529
529
  end
530
530
 
531
531
  it "sets the LogLevel option to ERROR if logger is not set to debug" do
532
532
  logger.level = ::Logger::INFO
533
533
  opts[:logger] = logger
534
534
 
535
- cmd.must_match regexify(" -o LogLevel=ERROR ")
535
+ args.must_match regexify(" -o LogLevel=ERROR ")
536
536
  end
537
537
 
538
538
  it "won't set the ForwardAgent option by default" do
539
- cmd.wont_match regexify(" -o ForwardAgent=")
539
+ args.wont_match regexify(" -o ForwardAgent=")
540
540
  end
541
541
 
542
542
  it "sets the ForwardAgent option to yes if truthy" do
543
543
  opts[:forward_agent] = "yep"
544
544
 
545
- cmd.must_match regexify(" -o ForwardAgent=yes")
545
+ args.must_match regexify(" -o ForwardAgent=yes")
546
546
  end
547
547
 
548
548
  it "sets the ForwardAgent option to no if falsey" do
549
549
  opts[:forward_agent] = false
550
550
 
551
- cmd.must_match regexify(" -o ForwardAgent=no")
551
+ args.must_match regexify(" -o ForwardAgent=no")
552
552
  end
553
553
 
554
554
  it "won't add any SSH keys by default" do
555
- cmd.wont_match regexify(" -i ")
555
+ args.wont_match regexify(" -i ")
556
556
  end
557
557
 
558
558
  it "sets SSH keys options if given" do
559
559
  opts[:keys] = %w[one two]
560
560
 
561
- cmd.must_match regexify(" -i one ")
562
- cmd.must_match regexify(" -i two ")
561
+ args.must_match regexify(" -i one ")
562
+ args.must_match regexify(" -i two ")
563
563
  end
564
564
 
565
565
  it "sets the port option to 22 by default" do
566
- cmd.must_match regexify(" -p 22 ")
566
+ args.must_match regexify(" -p 22 ")
567
567
  end
568
568
 
569
569
  it "sets the port option" do
570
570
  opts[:port] = 1234
571
571
 
572
- cmd.must_match regexify(" -p 1234 ")
572
+ args.must_match regexify(" -p 1234 ")
573
573
  end
574
574
  end
575
575