test-kitchen 1.14.1 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +1 -1
  3. data/CHANGELOG.md +7 -0
  4. data/Gemfile +1 -1
  5. data/Guardfile +5 -5
  6. data/Rakefile +5 -5
  7. data/bin/kitchen +1 -1
  8. data/features/step_definitions/gem_steps.rb +6 -6
  9. data/features/support/env.rb +6 -7
  10. data/lib/kitchen.rb +5 -7
  11. data/lib/kitchen/base64_stream.rb +2 -8
  12. data/lib/kitchen/cli.rb +76 -80
  13. data/lib/kitchen/collection.rb +0 -2
  14. data/lib/kitchen/color.rb +7 -9
  15. data/lib/kitchen/command.rb +0 -4
  16. data/lib/kitchen/command/action.rb +0 -3
  17. data/lib/kitchen/command/console.rb +4 -7
  18. data/lib/kitchen/command/diagnose.rb +7 -14
  19. data/lib/kitchen/command/driver_discover.rb +1 -4
  20. data/lib/kitchen/command/exec.rb +0 -3
  21. data/lib/kitchen/command/list.rb +9 -12
  22. data/lib/kitchen/command/login.rb +0 -3
  23. data/lib/kitchen/command/package.rb +0 -3
  24. data/lib/kitchen/command/sink.rb +6 -9
  25. data/lib/kitchen/command/test.rb +1 -4
  26. data/lib/kitchen/config.rb +25 -27
  27. data/lib/kitchen/configurable.rb +26 -31
  28. data/lib/kitchen/data_munger.rb +34 -36
  29. data/lib/kitchen/diagnostic.rb +5 -7
  30. data/lib/kitchen/driver.rb +3 -5
  31. data/lib/kitchen/driver/base.rb +0 -3
  32. data/lib/kitchen/driver/dummy.rb +0 -3
  33. data/lib/kitchen/driver/proxy.rb +0 -3
  34. data/lib/kitchen/driver/ssh_base.rb +13 -16
  35. data/lib/kitchen/errors.rb +11 -16
  36. data/lib/kitchen/generator/driver_create.rb +18 -21
  37. data/lib/kitchen/generator/init.rb +21 -26
  38. data/lib/kitchen/instance.rb +19 -23
  39. data/lib/kitchen/lazy_hash.rb +1 -2
  40. data/lib/kitchen/loader/yaml.rb +22 -25
  41. data/lib/kitchen/logger.rb +9 -14
  42. data/lib/kitchen/logging.rb +0 -3
  43. data/lib/kitchen/login_command.rb +0 -2
  44. data/lib/kitchen/metadata_chopper.rb +0 -2
  45. data/lib/kitchen/platform.rb +1 -3
  46. data/lib/kitchen/provisioner.rb +3 -5
  47. data/lib/kitchen/provisioner/base.rb +2 -5
  48. data/lib/kitchen/provisioner/chef/berkshelf.rb +1 -5
  49. data/lib/kitchen/provisioner/chef/common_sandbox.rb +24 -29
  50. data/lib/kitchen/provisioner/chef/librarian.rb +2 -6
  51. data/lib/kitchen/provisioner/chef/policyfile.rb +4 -8
  52. data/lib/kitchen/provisioner/chef_apply.rb +14 -17
  53. data/lib/kitchen/provisioner/chef_base.rb +43 -46
  54. data/lib/kitchen/provisioner/chef_solo.rb +10 -13
  55. data/lib/kitchen/provisioner/chef_zero.rb +22 -29
  56. data/lib/kitchen/provisioner/dummy.rb +0 -3
  57. data/lib/kitchen/provisioner/shell.rb +6 -9
  58. data/lib/kitchen/rake_tasks.rb +4 -6
  59. data/lib/kitchen/shell_out.rb +3 -5
  60. data/lib/kitchen/ssh.rb +16 -22
  61. data/lib/kitchen/state_file.rb +3 -5
  62. data/lib/kitchen/suite.rb +0 -2
  63. data/lib/kitchen/thor_tasks.rb +2 -4
  64. data/lib/kitchen/transport.rb +3 -5
  65. data/lib/kitchen/transport/base.rb +1 -7
  66. data/lib/kitchen/transport/dummy.rb +0 -4
  67. data/lib/kitchen/transport/ssh.rb +41 -47
  68. data/lib/kitchen/transport/winrm.rb +41 -40
  69. data/lib/kitchen/util.rb +1 -3
  70. data/lib/kitchen/verifier.rb +3 -5
  71. data/lib/kitchen/verifier/base.rb +2 -5
  72. data/lib/kitchen/verifier/busser.rb +24 -24
  73. data/lib/kitchen/verifier/dummy.rb +0 -3
  74. data/lib/kitchen/verifier/shell.rb +1 -3
  75. data/lib/kitchen/version.rb +1 -1
  76. data/lib/vendor/hash_recursive_merge.rb +0 -2
  77. data/spec/kitchen/base64_stream_spec.rb +3 -6
  78. data/spec/kitchen/cli_spec.rb +0 -2
  79. data/spec/kitchen/collection_spec.rb +4 -8
  80. data/spec/kitchen/color_spec.rb +0 -3
  81. data/spec/kitchen/config_spec.rb +91 -106
  82. data/spec/kitchen/configurable_spec.rb +44 -76
  83. data/spec/kitchen/data_munger_spec.rb +1178 -1247
  84. data/spec/kitchen/diagnostic_spec.rb +37 -38
  85. data/spec/kitchen/driver/base_spec.rb +7 -14
  86. data/spec/kitchen/driver/dummy_spec.rb +1 -7
  87. data/spec/kitchen/driver/proxy_spec.rb +2 -7
  88. data/spec/kitchen/driver/ssh_base_spec.rb +128 -149
  89. data/spec/kitchen/driver_spec.rb +7 -13
  90. data/spec/kitchen/errors_spec.rb +50 -60
  91. data/spec/kitchen/instance_spec.rb +217 -294
  92. data/spec/kitchen/lazy_hash_spec.rb +14 -18
  93. data/spec/kitchen/loader/yaml_spec.rb +201 -227
  94. data/spec/kitchen/logger_spec.rb +7 -15
  95. data/spec/kitchen/logging_spec.rb +1 -4
  96. data/spec/kitchen/login_command_spec.rb +3 -4
  97. data/spec/kitchen/metadata_chopper_spec.rb +0 -3
  98. data/spec/kitchen/platform_spec.rb +31 -32
  99. data/spec/kitchen/provisioner/base_spec.rb +22 -41
  100. data/spec/kitchen/provisioner/chef/policyfile_spec.rb +15 -15
  101. data/spec/kitchen/provisioner/chef_apply_spec.rb +8 -13
  102. data/spec/kitchen/provisioner/chef_base_spec.rb +150 -182
  103. data/spec/kitchen/provisioner/chef_solo_spec.rb +58 -72
  104. data/spec/kitchen/provisioner/chef_zero_spec.rb +99 -125
  105. data/spec/kitchen/provisioner/dummy_spec.rb +8 -11
  106. data/spec/kitchen/provisioner/shell_spec.rb +86 -103
  107. data/spec/kitchen/provisioner_spec.rb +5 -11
  108. data/spec/kitchen/shell_out_spec.rb +15 -19
  109. data/spec/kitchen/ssh_spec.rb +16 -35
  110. data/spec/kitchen/state_file_spec.rb +6 -11
  111. data/spec/kitchen/suite_spec.rb +5 -6
  112. data/spec/kitchen/transport/base_spec.rb +6 -14
  113. data/spec/kitchen/transport/ssh_spec.rb +39 -64
  114. data/spec/kitchen/transport/winrm_spec.rb +99 -127
  115. data/spec/kitchen/transport_spec.rb +7 -13
  116. data/spec/kitchen/util_spec.rb +17 -26
  117. data/spec/kitchen/verifier/base_spec.rb +24 -40
  118. data/spec/kitchen/verifier/busser_spec.rb +38 -68
  119. data/spec/kitchen/verifier/dummy_spec.rb +8 -11
  120. data/spec/kitchen/verifier/shell_spec.rb +14 -17
  121. data/spec/kitchen/verifier_spec.rb +7 -13
  122. data/spec/kitchen_spec.rb +4 -6
  123. data/spec/spec_helper.rb +1 -1
  124. data/spec/support/powershell_max_size_spec.rb +1 -2
  125. data/support/chef-client-zero.rb +3 -4
  126. data/test-kitchen.gemspec +4 -6
  127. metadata +9 -9
@@ -21,13 +21,12 @@ require_relative "../../spec_helper"
21
21
  require "kitchen"
22
22
 
23
23
  describe Kitchen::Transport::Base do
24
-
25
24
  let(:logged_output) { StringIO.new }
26
25
  let(:logger) { Logger.new(logged_output) }
27
26
  let(:config) { Hash.new }
28
27
 
29
28
  let(:instance) do
30
- stub(:name => "coolbeans", :logger => logger)
29
+ stub(name: "coolbeans", logger: logger)
31
30
  end
32
31
 
33
32
  let(:transport) do
@@ -39,7 +38,6 @@ describe Kitchen::Transport::Base do
39
38
  end
40
39
 
41
40
  describe "#logger" do
42
-
43
41
  before { @klog = Kitchen.logger }
44
42
  after { Kitchen.logger = @klog }
45
43
 
@@ -56,32 +54,27 @@ describe Kitchen::Transport::Base do
56
54
  end
57
55
 
58
56
  describe Kitchen::Transport::TransportFailed do
59
-
60
57
  let(:failure_with_no_exit_code) { Kitchen::Transport::TransportFailed.new("Boom") }
61
58
  let(:failure_with_exit_code) { Kitchen::Transport::TransportFailed.new("Boom", 123) }
62
59
 
63
60
  describe "when no exit code is provided" do
64
-
65
61
  it "#exit_code is nil" do
66
62
  failure_with_no_exit_code.exit_code.must_be_nil
67
63
  end
68
64
  end
69
65
 
70
66
  describe "when an exit code is provided" do
71
-
72
67
  it "#exit_code returns the supplied exit code" do
73
68
  failure_with_exit_code.exit_code.must_equal 123
74
69
  end
75
70
  end
76
71
  end
77
-
78
72
  end
79
73
 
80
74
  describe Kitchen::Transport::Base::Connection do
81
-
82
75
  let(:logged_output) { StringIO.new }
83
76
  let(:logger) { Logger.new(logged_output) }
84
- let(:options) { { :logger => logger } }
77
+ let(:options) { { logger: logger } }
85
78
 
86
79
  let(:connection) do
87
80
  Kitchen::Transport::Base::Connection.new(options)
@@ -100,8 +93,8 @@ describe Kitchen::Transport::Base::Connection do
100
93
  end
101
94
 
102
95
  it "has an #upload method which raises a ClientError" do
103
- proc { connection.upload(["file"], "/path/to") }.
104
- must_raise Kitchen::ClientError
96
+ proc { connection.upload(["file"], "/path/to") }
97
+ .must_raise Kitchen::ClientError
105
98
  end
106
99
 
107
100
  it "has a #wait_until_ready method that does nothing" do
@@ -109,12 +102,11 @@ describe Kitchen::Transport::Base::Connection do
109
102
  end
110
103
 
111
104
  describe "#execute_with_retry" do
112
-
113
105
  let(:failure_with_exit_code) { Kitchen::Transport::TransportFailed.new("Boom", 123) }
114
106
 
115
107
  it "raises ClientError with no retries" do
116
- proc { connection.execute_with_retry("hi", [], nil, nil) }.
117
- must_raise Kitchen::ClientError
108
+ proc { connection.execute_with_retry("hi", [], nil, nil) }
109
+ .must_raise Kitchen::ClientError
118
110
  end
119
111
 
120
112
  it "retries three times" do
@@ -86,13 +86,9 @@ end
86
86
  # An upstream patch to Net::SSH will be required to retire this yak shave ;)
87
87
  require "net/ssh/test/channel"
88
88
  module Net
89
-
90
89
  module SSH
91
-
92
90
  module Test
93
-
94
91
  class Channel
95
-
96
92
  def sends_request_pty
97
93
  pty_data = ["xterm", 80, 24, 640, 480, "\0"]
98
94
 
@@ -115,14 +111,13 @@ module Net
115
111
  end
116
112
 
117
113
  describe Kitchen::Transport::Ssh do
118
-
119
114
  let(:logged_output) { StringIO.new }
120
115
  let(:logger) { Logger.new(logged_output) }
121
116
  let(:config) { Hash.new }
122
117
  let(:state) { Hash.new }
123
118
 
124
119
  let(:instance) do
125
- stub(:name => "coolbeans", :logger => logger, :to_str => "instance")
120
+ stub(name: "coolbeans", logger: logger, to_str: "instance")
126
121
  end
127
122
 
128
123
  let(:transport) do
@@ -138,7 +133,6 @@ describe Kitchen::Transport::Ssh do
138
133
  end
139
134
 
140
135
  describe "default_config" do
141
-
142
136
  it "sets :port to 22 by default" do
143
137
  transport[:port].must_equal 22
144
138
  end
@@ -214,7 +208,6 @@ describe Kitchen::Transport::Ssh do
214
208
  end
215
209
 
216
210
  describe "#connection" do
217
-
218
211
  let(:klass) { Kitchen::Transport::Ssh::Connection }
219
212
 
220
213
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
@@ -642,14 +635,14 @@ describe Kitchen::Transport::Ssh do
642
635
  make_connection(state)
643
636
  make_connection(state)
644
637
 
645
- logged_output.string.lines.count { |l|
638
+ logged_output.string.lines.count do |l|
646
639
  l =~ debug_line_with("[SSH] reusing existing connection ")
647
- }.must_equal 1
640
+ end.must_equal 1
648
641
  end
649
642
 
650
643
  it "returns a new connection when called again if state differs" do
651
644
  first_connection = make_connection(state)
652
- second_connection = make_connection(state.merge(:port => 9000))
645
+ second_connection = make_connection(state.merge(port: 9000))
653
646
 
654
647
  first_connection.object_id.wont_equal second_connection.object_id
655
648
  end
@@ -658,22 +651,21 @@ describe Kitchen::Transport::Ssh do
658
651
  first_connection = make_connection(state)
659
652
  first_connection.expects(:close)
660
653
 
661
- make_connection(state.merge(:port => 9000))
654
+ make_connection(state.merge(port: 9000))
662
655
  end
663
656
 
664
657
  it "logs a debug message a second connection is created" do
665
658
  make_connection(state)
666
- make_connection(state.merge(:port => 9000))
659
+ make_connection(state.merge(port: 9000))
667
660
 
668
- logged_output.string.lines.count { |l|
661
+ logged_output.string.lines.count do |l|
669
662
  l =~ debug_line_with("[SSH] shutting previous connection ")
670
- }.must_equal 1
663
+ end.must_equal 1
671
664
  end
672
665
  end
673
666
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
674
667
 
675
668
  describe "called without a block" do
676
-
677
669
  def make_connection(s = state)
678
670
  transport.connection(s)
679
671
  end
@@ -682,7 +674,6 @@ describe Kitchen::Transport::Ssh do
682
674
  end
683
675
 
684
676
  describe "called with a block" do
685
-
686
677
  def make_connection(s = state)
687
678
  transport.connection(s) do |conn|
688
679
  conn
@@ -694,12 +685,11 @@ describe Kitchen::Transport::Ssh do
694
685
  end
695
686
 
696
687
  def debug_line_with(msg)
697
- %r{^D, .* : #{Regexp.escape(msg)}}
688
+ /^D, .* : #{Regexp.escape(msg)}/
698
689
  end
699
690
  end
700
691
 
701
692
  describe Kitchen::Transport::Ssh::Connection do
702
-
703
693
  include Net::SSH::Test
704
694
  # sadly, Net:SSH::Test includes a #connection method so we'll alias this one
705
695
  # before redefining it
@@ -711,11 +701,11 @@ describe Kitchen::Transport::Ssh::Connection do
711
701
 
712
702
  let(:options) do
713
703
  {
714
- :logger => logger,
715
- :username => "me",
716
- :hostname => "foo",
717
- :port => 22,
718
- :max_ssh_sessions => 9
704
+ logger: logger,
705
+ username: "me",
706
+ hostname: "foo",
707
+ port: 22,
708
+ max_ssh_sessions: 9,
719
709
  }
720
710
  end
721
711
 
@@ -734,7 +724,6 @@ describe Kitchen::Transport::Ssh::Connection do
734
724
  end
735
725
 
736
726
  describe "establishing a connection" do
737
-
738
727
  [
739
728
  Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED, Errno::ETIMEDOUT,
740
729
  Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH,
@@ -742,7 +731,6 @@ describe Kitchen::Transport::Ssh::Connection do
742
731
  Timeout::Error
743
732
  ].each do |klass|
744
733
  describe "raising #{klass}" do
745
-
746
734
  before do
747
735
  Net::SSH.stubs(:start).raises(klass)
748
736
  options[:connection_retries] = 3
@@ -751,9 +739,9 @@ describe Kitchen::Transport::Ssh::Connection do
751
739
  end
752
740
 
753
741
  it "raises an SshFailed exception" do
754
- e = proc {
742
+ e = proc do
755
743
  connection.execute("nope")
756
- }.must_raise Kitchen::Transport::SshFailed
744
+ end.must_raise Kitchen::Transport::SshFailed
757
745
  e.message.must_match regexify("SSH session could not be established")
758
746
  end
759
747
 
@@ -764,9 +752,9 @@ describe Kitchen::Transport::Ssh::Connection do
764
752
  # the raise is not what is being tested here, rather its side-effect
765
753
  end
766
754
 
767
- logged_output.string.lines.count { |l|
755
+ logged_output.string.lines.count do |l|
768
756
  l =~ debug_line("[SSH] opening connection to me@foo<{:port=>22}>")
769
- }.must_equal 3
757
+ end.must_equal 3
770
758
  end
771
759
 
772
760
  it "sleeps for :connection_retry_sleep seconds between retries" do
@@ -787,10 +775,10 @@ describe Kitchen::Transport::Ssh::Connection do
787
775
  # the raise is not what is being tested here, rather its side-effect
788
776
  end
789
777
 
790
- logged_output.string.lines.count { |l|
778
+ logged_output.string.lines.count do |l|
791
779
  l =~ info_line_with(
792
780
  "[SSH] connection failed, retrying in 7 seconds")
793
- }.must_equal 2
781
+ end.must_equal 2
794
782
  end
795
783
 
796
784
  it "logs the last retry failures on warn" do
@@ -800,16 +788,15 @@ describe Kitchen::Transport::Ssh::Connection do
800
788
  # the raise is not what is being tested here, rather its side-effect
801
789
  end
802
790
 
803
- logged_output.string.lines.count { |l|
791
+ logged_output.string.lines.count do |l|
804
792
  l =~ warn_line_with("[SSH] connection failed, terminating ")
805
- }.must_equal 1
793
+ end.must_equal 1
806
794
  end
807
795
  end
808
796
  end
809
797
  end
810
798
 
811
799
  describe "#close" do
812
-
813
800
  before do
814
801
  story do |script|
815
802
  channel = script.opens_channel
@@ -848,9 +835,7 @@ describe Kitchen::Transport::Ssh::Connection do
848
835
  end
849
836
 
850
837
  describe "#execute" do
851
-
852
838
  describe "for a successful command" do
853
-
854
839
  before do
855
840
  story do |script|
856
841
  channel = script.opens_channel
@@ -894,7 +879,6 @@ describe Kitchen::Transport::Ssh::Connection do
894
879
  end
895
880
 
896
881
  describe "for a failed command" do
897
-
898
882
  before do
899
883
  story do |script|
900
884
  channel = script.opens_channel
@@ -953,9 +937,9 @@ describe Kitchen::Transport::Ssh::Connection do
953
937
  end
954
938
 
955
939
  it "raises an SshFailed exception" do
956
- err = proc {
940
+ err = proc do
957
941
  connection.execute("doit")
958
- }.must_raise Kitchen::Transport::SshFailed
942
+ end.must_raise Kitchen::Transport::SshFailed
959
943
  err.message.must_equal "SSH exited (42) for command: [doit]"
960
944
  end
961
945
 
@@ -969,7 +953,6 @@ describe Kitchen::Transport::Ssh::Connection do
969
953
  end
970
954
 
971
955
  describe "for an interrupted command" do
972
-
973
956
  let(:conn) { mock("session") }
974
957
 
975
958
  before do
@@ -979,15 +962,14 @@ describe Kitchen::Transport::Ssh::Connection do
979
962
  it "raises SshFailed when an SSH exception is raised" do
980
963
  conn.stubs(:open_channel).raises(Net::SSH::Exception)
981
964
 
982
- e = proc {
965
+ e = proc do
983
966
  connection.execute("nope")
984
- }.must_raise Kitchen::Transport::SshFailed
967
+ end.must_raise Kitchen::Transport::SshFailed
985
968
  e.message.must_match regexify("SSH command failed")
986
969
  end
987
970
  end
988
971
 
989
972
  describe "for a nil command" do
990
-
991
973
  it "does not log on debug" do
992
974
  connection.execute(nil)
993
975
 
@@ -997,7 +979,6 @@ describe Kitchen::Transport::Ssh::Connection do
997
979
  end
998
980
 
999
981
  describe "#login_command" do
1000
-
1001
982
  let(:login_command) { connection.login_command }
1002
983
  let(:args) { login_command.arguments.join(" ") }
1003
984
 
@@ -1063,7 +1044,7 @@ describe Kitchen::Transport::Ssh::Connection do
1063
1044
  end
1064
1045
 
1065
1046
  it "sets SSH keys options if given" do
1066
- options[:keys] = %w[one two]
1047
+ options[:keys] = %w{one two}
1067
1048
 
1068
1049
  args.must_match regexify(" -i one ")
1069
1050
  args.must_match regexify(" -i two ")
@@ -1081,9 +1062,7 @@ describe Kitchen::Transport::Ssh::Connection do
1081
1062
  end
1082
1063
 
1083
1064
  describe "#upload" do
1084
-
1085
1065
  describe "for a file" do
1086
-
1087
1066
  let(:content) { "a" * 1234 }
1088
1067
 
1089
1068
  let(:src) do
@@ -1176,7 +1155,6 @@ describe Kitchen::Transport::Ssh::Connection do
1176
1155
  end
1177
1156
 
1178
1157
  describe "for a failed upload" do
1179
-
1180
1158
  let(:conn) { mock("session") }
1181
1159
 
1182
1160
  before do
@@ -1186,23 +1164,21 @@ describe Kitchen::Transport::Ssh::Connection do
1186
1164
  it "raises SshFailed when an SSH exception is raised" do
1187
1165
  conn.stubs(:scp).raises(Net::SSH::Exception)
1188
1166
 
1189
- e = proc {
1167
+ e = proc do
1190
1168
  connection.upload("nope", "fail")
1191
- }.must_raise Kitchen::Transport::SshFailed
1169
+ end.must_raise Kitchen::Transport::SshFailed
1192
1170
  e.message.must_match regexify("SCP upload failed")
1193
1171
  end
1194
1172
  end
1195
1173
  end
1196
1174
 
1197
1175
  describe "#wait_until_ready" do
1198
-
1199
1176
  before do
1200
1177
  options[:max_wait_until_ready] = 300
1201
1178
  connection.stubs(:sleep)
1202
1179
  end
1203
1180
 
1204
1181
  describe "when failing to connect" do
1205
-
1206
1182
  before do
1207
1183
  Net::SSH.stubs(:start).raises(Errno::ECONNREFUSED)
1208
1184
  end
@@ -1214,16 +1190,16 @@ describe Kitchen::Transport::Ssh::Connection do
1214
1190
  # the raise is not what is being tested here, rather its side-effect
1215
1191
  end
1216
1192
 
1217
- logged_output.string.lines.count { |l|
1193
+ logged_output.string.lines.count do |l|
1218
1194
  l =~ info_line_with(
1219
1195
  "Waiting for SSH service on foo:22, retrying in 3 seconds")
1220
- }.must_equal((300 / 3) - 1)
1221
- logged_output.string.lines.count { |l|
1196
+ end.must_equal((300 / 3) - 1)
1197
+ logged_output.string.lines.count do |l|
1222
1198
  l =~ debug_line_with("[SSH] connection failed ")
1223
- }.must_equal((300 / 3) - 1)
1224
- logged_output.string.lines.count { |l|
1199
+ end.must_equal((300 / 3) - 1)
1200
+ logged_output.string.lines.count do |l|
1225
1201
  l =~ warn_line_with("[SSH] connection failed, terminating ")
1226
- }.must_equal 1
1202
+ end.must_equal 1
1227
1203
  end
1228
1204
 
1229
1205
  it "sleeps for 3 seconds between retries" do
@@ -1239,7 +1215,6 @@ describe Kitchen::Transport::Ssh::Connection do
1239
1215
  end
1240
1216
 
1241
1217
  describe "when connection is successful" do
1242
-
1243
1218
  before do
1244
1219
  story do |script|
1245
1220
  channel = script.opens_channel
@@ -1278,15 +1253,15 @@ describe Kitchen::Transport::Ssh::Connection do
1278
1253
  end
1279
1254
 
1280
1255
  def debug_line(msg)
1281
- %r{^D, .* : #{Regexp.escape(msg)}$}
1256
+ /^D, .* : #{Regexp.escape(msg)}$/
1282
1257
  end
1283
1258
 
1284
1259
  def debug_line_with(msg)
1285
- %r{^D, .* : #{Regexp.escape(msg)}}
1260
+ /^D, .* : #{Regexp.escape(msg)}/
1286
1261
  end
1287
1262
 
1288
1263
  def info_line_with(msg)
1289
- %r{^I, .* : #{Regexp.escape(msg)}}
1264
+ /^I, .* : #{Regexp.escape(msg)}/
1290
1265
  end
1291
1266
 
1292
1267
  def regexify(string)
@@ -1294,6 +1269,6 @@ describe Kitchen::Transport::Ssh::Connection do
1294
1269
  end
1295
1270
 
1296
1271
  def warn_line_with(msg)
1297
- %r{^W, .* : #{Regexp.escape(msg)}}
1272
+ /^W, .* : #{Regexp.escape(msg)}/
1298
1273
  end
1299
1274
  end
@@ -24,11 +24,8 @@ require "winrm-fs"
24
24
  require "winrm-elevated"
25
25
 
26
26
  module Kitchen
27
-
28
27
  module Transport
29
-
30
28
  class WinRMConnectionDummy < Kitchen::Transport::Winrm::Connection
31
-
32
29
  attr_reader :saved_command, :remote_path, :local_path
33
30
 
34
31
  def upload(locals, remote)
@@ -41,7 +38,6 @@ module Kitchen
41
38
  end
42
39
 
43
40
  describe Kitchen::Transport::Winrm do
44
-
45
41
  before do
46
42
  RbConfig::CONFIG.stubs(:[]).with("host_os").returns("blah")
47
43
  end
@@ -52,7 +48,7 @@ describe Kitchen::Transport::Winrm do
52
48
  let(:state) { Hash.new }
53
49
 
54
50
  let(:instance) do
55
- stub(:name => "coolbeans", :logger => logger, :to_str => "instance")
51
+ stub(name: "coolbeans", logger: logger, to_str: "instance")
56
52
  end
57
53
 
58
54
  let(:transport) do
@@ -72,7 +68,6 @@ describe Kitchen::Transport::Winrm do
72
68
  end
73
69
 
74
70
  describe "default_config" do
75
-
76
71
  it "sets :port to 5985 by default" do
77
72
  transport[:port].must_equal 5985
78
73
  end
@@ -86,8 +81,8 @@ describe Kitchen::Transport::Winrm do
86
81
  end
87
82
 
88
83
  it "sets a default :endpoint_template value" do
89
- transport[:endpoint_template].
90
- must_equal "http://%{hostname}:%{port}/wsman"
84
+ transport[:endpoint_template]
85
+ .must_equal "http://%{hostname}:%{port}/wsman"
91
86
  end
92
87
 
93
88
  it "sets :rdp_port to 3389 by default" do
@@ -116,7 +111,6 @@ describe Kitchen::Transport::Winrm do
116
111
  end
117
112
 
118
113
  describe "#connection" do
119
-
120
114
  let(:klass) { Kitchen::Transport::Winrm::Connection }
121
115
 
122
116
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
@@ -391,7 +385,6 @@ describe Kitchen::Transport::Winrm do
391
385
  end
392
386
 
393
387
  it "sets :winrm_transport to negotiate" do
394
-
395
388
  klass.expects(:new).with do |hash|
396
389
  hash[:transport] == :negotiate &&
397
390
  hash[:disable_sspi] == false &&
@@ -413,14 +406,14 @@ describe Kitchen::Transport::Winrm do
413
406
  make_connection(state)
414
407
  make_connection(state)
415
408
 
416
- logged_output.string.lines.count { |l|
409
+ logged_output.string.lines.count do |l|
417
410
  l =~ debug_line_with("[WinRM] reusing existing connection ")
418
- }.must_equal 1
411
+ end.must_equal 1
419
412
  end
420
413
 
421
414
  it "returns a new connection when called again if state differs" do
422
415
  first_connection = make_connection(state)
423
- second_connection = make_connection(state.merge(:port => 9000))
416
+ second_connection = make_connection(state.merge(port: 9000))
424
417
 
425
418
  first_connection.object_id.wont_equal second_connection.object_id
426
419
  end
@@ -429,22 +422,21 @@ describe Kitchen::Transport::Winrm do
429
422
  first_connection = make_connection(state)
430
423
  first_connection.expects(:close)
431
424
 
432
- make_connection(state.merge(:port => 9000))
425
+ make_connection(state.merge(port: 9000))
433
426
  end
434
427
 
435
428
  it "logs a debug message a second connection is created" do
436
429
  make_connection(state)
437
- make_connection(state.merge(:port => 9000))
430
+ make_connection(state.merge(port: 9000))
438
431
 
439
- logged_output.string.lines.count { |l|
432
+ logged_output.string.lines.count do |l|
440
433
  l =~ debug_line_with("[WinRM] shutting previous connection ")
441
- }.must_equal 1
434
+ end.must_equal 1
442
435
  end
443
436
  end
444
437
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
445
438
 
446
439
  describe "called without a block" do
447
-
448
440
  def make_connection(s = state)
449
441
  transport.connection(s)
450
442
  end
@@ -453,7 +445,6 @@ describe Kitchen::Transport::Winrm do
453
445
  end
454
446
 
455
447
  describe "called with a block" do
456
-
457
448
  def make_connection(s = state)
458
449
  transport.connection(s) do |conn|
459
450
  conn
@@ -528,8 +519,8 @@ describe Kitchen::Transport::Winrm do
528
519
  it "logs a message to fatal when libraries cannot be loaded" do
529
520
  transport = Kitchen::Transport::Winrm.new(config)
530
521
  transport.stubs(:require).with("winrm", anything)
531
- transport.stubs(:require).with("winrm-fs").
532
- raises(LoadError, "uh oh")
522
+ transport.stubs(:require).with("winrm-fs")
523
+ .raises(LoadError, "uh oh")
533
524
  begin
534
525
  transport.finalize_config!(instance)
535
526
  rescue # rubocop:disable Lint/HandleExceptions
@@ -543,12 +534,12 @@ describe Kitchen::Transport::Winrm do
543
534
  it "raises a UserError when libraries cannot be loaded" do
544
535
  transport = Kitchen::Transport::Winrm.new(config)
545
536
  transport.stubs(:require).with("winrm", anything)
546
- transport.stubs(:require).with("winrm-fs").
547
- raises(LoadError, "uh oh")
537
+ transport.stubs(:require).with("winrm-fs")
538
+ .raises(LoadError, "uh oh")
548
539
 
549
- err = proc {
540
+ err = proc do
550
541
  transport.finalize_config!(instance)
551
- }.must_raise Kitchen::UserError
542
+ end.must_raise Kitchen::UserError
552
543
  err.message.must_match(/^Could not load or activate winrm-fs\. /)
553
544
  end
554
545
  end
@@ -607,41 +598,40 @@ describe Kitchen::Transport::Winrm do
607
598
  transport.stubs(:require).with("winrm-fs", anything)
608
599
  transport.stubs(:require).raises(LoadError, "uh oh")
609
600
 
610
- err = proc {
601
+ err = proc do
611
602
  transport.finalize_config!(instance)
612
- }.must_raise Kitchen::UserError
603
+ end.must_raise Kitchen::UserError
613
604
  err.message.must_match(/^Could not load or activate winrm\. /)
614
605
  end
615
606
  end
616
607
  end
617
608
 
618
609
  def debug_line_with(msg)
619
- %r{^D, .* : #{Regexp.escape(msg)}}
610
+ /^D, .* : #{Regexp.escape(msg)}/
620
611
  end
621
612
 
622
613
  def fatal_line_with(msg)
623
- %r{^F, .* : #{Regexp.escape(msg)}}
614
+ /^F, .* : #{Regexp.escape(msg)}/
624
615
  end
625
616
  end
626
617
 
627
618
  describe Kitchen::Transport::Winrm::Connection do
628
-
629
619
  let(:logged_output) { StringIO.new }
630
620
  let(:logger) { Logger.new(logged_output) }
631
621
 
632
622
  let(:options) do
633
- { :logger => logger, :user => "me", :password => "haha",
634
- :endpoint => "http://foo:5985/wsman", :winrm_transport => :plaintext,
635
- :kitchen_root => "/i/am/root", :instance_name => "coolbeans",
636
- :rdp_port => "rdpyeah" }
623
+ { logger: logger, user: "me", password: "haha",
624
+ endpoint: "http://foo:5985/wsman", winrm_transport: :plaintext,
625
+ kitchen_root: "/i/am/root", instance_name: "coolbeans",
626
+ rdp_port: "rdpyeah" }
637
627
  end
638
628
 
639
629
  let(:info) do
640
630
  copts = {
641
- :user => "me",
642
- :password => "haha",
643
- :endpoint => "http://foo:5985/wsman",
644
- :winrm_transport => :plaintext
631
+ user: "me",
632
+ password: "haha",
633
+ endpoint: "http://foo:5985/wsman",
634
+ winrm_transport: :plaintext,
645
635
  }
646
636
  "<#{copts}>"
647
637
  end
@@ -681,11 +671,10 @@ describe Kitchen::Transport::Winrm::Connection do
681
671
  end
682
672
 
683
673
  describe "#close" do
684
-
685
674
  let(:response) do
686
675
  o = WinRM::Output.new
687
676
  o.exitcode = 0
688
- o << { :stdout => "ok\r\n" }
677
+ o << { stdout: "ok\r\n" }
689
678
  o
690
679
  end
691
680
 
@@ -695,10 +684,10 @@ describe Kitchen::Transport::Winrm::Connection do
695
684
  winrm_session.stubs(:shell).with(:powershell).returns(executor)
696
685
  executor.stubs(:close)
697
686
  elevated_runner.stubs(:close)
698
- executor.stubs(:run).
699
- with("doit").yields("ok\n", nil).returns(response)
700
- executor.stubs(:run).
701
- with("$env:temp").yields("ok\n", nil).returns(response)
687
+ executor.stubs(:run)
688
+ .with("doit").yields("ok\n", nil).returns(response)
689
+ executor.stubs(:run)
690
+ .with("$env:temp").yields("ok\n", nil).returns(response)
702
691
  end
703
692
 
704
693
  it "only closes the shell once for multiple calls" do
@@ -732,24 +721,22 @@ describe Kitchen::Transport::Winrm::Connection do
732
721
  end
733
722
 
734
723
  describe "#execute" do
735
-
736
724
  before do
737
725
  winrm_session.stubs(:shell).with(:powershell).returns(executor)
738
726
  end
739
727
 
740
728
  describe "for a successful command" do
741
-
742
729
  let(:response) do
743
730
  o = WinRM::Output.new
744
731
  o.exitcode = 0
745
- o << { :stdout => "ok\r\n" }
746
- o << { :stderr => "congrats\r\n" }
732
+ o << { stdout: "ok\r\n" }
733
+ o << { stderr: "congrats\r\n" }
747
734
  o
748
735
  end
749
736
 
750
737
  before do
751
- executor.expects(:run).
752
- with("doit").yields("ok\n", nil).returns(response)
738
+ executor.expects(:run)
739
+ .with("doit").yields("ok\n", nil).returns(response)
753
740
  end
754
741
 
755
742
  it "logger displays command on debug" do
@@ -784,14 +771,14 @@ describe Kitchen::Transport::Winrm::Connection do
784
771
  let(:response) do
785
772
  o = WinRM::Output.new
786
773
  o.exitcode = 0
787
- o << { :stdout => "ok\r\n" }
788
- o << { :stderr => "congrats\r\n" }
774
+ o << { stdout: "ok\r\n" }
775
+ o << { stderr: "congrats\r\n" }
789
776
  o
790
777
  end
791
778
  let(:env_temp_response) do
792
779
  o = WinRM::Output.new
793
780
  o.exitcode = 0
794
- o << { :stdout => "temp_dir" }
781
+ o << { stdout: "temp_dir" }
795
782
  o
796
783
  end
797
784
  let(:elevated_runner) do
@@ -809,10 +796,10 @@ describe Kitchen::Transport::Winrm::Connection do
809
796
  before do
810
797
  options[:elevated_username] = "username"
811
798
  options[:elevated_password] = "password"
812
- executor.expects(:run).
813
- with("$env:temp").returns(env_temp_response)
814
- elevated_runner.expects(:run).
815
- with(
799
+ executor.expects(:run)
800
+ .with("$env:temp").returns(env_temp_response)
801
+ elevated_runner.expects(:run)
802
+ .with(
816
803
  "$env:temp='temp_dir';doit"
817
804
  ).yields("ok\n", nil).returns(response)
818
805
  elevated_runner.expects(:username=).with("username")
@@ -830,10 +817,10 @@ describe Kitchen::Transport::Winrm::Connection do
830
817
  before do
831
818
  options[:elevated_username] = options[:user]
832
819
  options[:elevated_password] = options[:password]
833
- executor.expects(:run).
834
- with("$env:temp").returns(env_temp_response)
835
- elevated_runner.expects(:run).
836
- with(
820
+ executor.expects(:run)
821
+ .with("$env:temp").returns(env_temp_response)
822
+ elevated_runner.expects(:run)
823
+ .with(
837
824
  "$env:temp='temp_dir';doit"
838
825
  ).yields("ok\n", nil).returns(response)
839
826
  elevated_runner.expects(:username=).with(options[:user])
@@ -849,35 +836,34 @@ describe Kitchen::Transport::Winrm::Connection do
849
836
  end
850
837
 
851
838
  describe "for a failed command" do
852
-
853
839
  let(:response) do
854
840
  o = WinRM::Output.new
855
841
  o.exitcode = 1
856
- o << { :stderr => "#< CLIXML\r\n" }
857
- o << { :stderr => "<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas." }
858
- o << { :stderr => "microsoft.com/powershell/2004/04\"><S S=\"Error\">" }
859
- o << { :stderr => "doit : The term 'doit' is not recognized as the " }
860
- o << { :stderr => "name of a cmdlet, function, _x000D__x000A_</S>" }
861
- o << { :stderr => "<S S=\"Error\">script file, or operable program. " }
862
- o << { :stderr => "Check the spelling of" }
863
- o << { :stderr => "the name, or if a path _x000D__x000A_</S><S S=\"E" }
864
- o << { :stderr => "rror\">was included, verify that the path is corr" }
865
- o << { :stderr => "ect and try again._x000D__x000A_</S><S S=\"Error" }
866
- o << { :stderr => "\">At line:1 char:1_x000D__x000A_</S><S S=\"Error" }
867
- o << { :stderr => "\">+ doit_x000D__x000A_</S><S S=\"Error\">+ ~~~~_" }
868
- o << { :stderr => "x000D__x000A_</S><S S=\"Error\"> + CategoryInf" }
869
- o << { :stderr => "o : ObjectNotFound: (doit:String) [], Co" }
870
- o << { :stderr => "mmandNotFoun _x000D__x000A_</S><S S=\"Error\"> " }
871
- o << { :stderr => "dException_x000D__x000A_</S><S S=\"Error\"> + " }
872
- o << { :stderr => "FullyQualifiedErrorId : CommandNotFoundException_" }
873
- o << { :stderr => "x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</" }
874
- o << { :stderr => "S></Objs>" }
842
+ o << { stderr: "#< CLIXML\r\n" }
843
+ o << { stderr: '<Objs Version="1.1.0.1" xmlns="http://schemas.' }
844
+ o << { stderr: 'microsoft.com/powershell/2004/04"><S S="Error">' }
845
+ o << { stderr: "doit : The term 'doit' is not recognized as the " }
846
+ o << { stderr: "name of a cmdlet, function, _x000D__x000A_</S>" }
847
+ o << { stderr: '<S S="Error">script file, or operable program. ' }
848
+ o << { stderr: "Check the spelling of" }
849
+ o << { stderr: 'the name, or if a path _x000D__x000A_</S><S S="E' }
850
+ o << { stderr: 'rror">was included, verify that the path is corr' }
851
+ o << { stderr: 'ect and try again._x000D__x000A_</S><S S="Error' }
852
+ o << { stderr: '">At line:1 char:1_x000D__x000A_</S><S S="Error' }
853
+ o << { stderr: '">+ doit_x000D__x000A_</S><S S="Error">+ ~~~~_' }
854
+ o << { stderr: 'x000D__x000A_</S><S S="Error"> + CategoryInf' }
855
+ o << { stderr: "o : ObjectNotFound: (doit:String) [], Co" }
856
+ o << { stderr: 'mmandNotFoun _x000D__x000A_</S><S S="Error"> ' }
857
+ o << { stderr: 'dException_x000D__x000A_</S><S S="Error"> + ' }
858
+ o << { stderr: "FullyQualifiedErrorId : CommandNotFoundException_" }
859
+ o << { stderr: 'x000D__x000A_</S><S S="Error"> _x000D__x000A_</' }
860
+ o << { stderr: "S></Objs>" }
875
861
  o
876
862
  end
877
863
 
878
864
  before do
879
- executor.expects(:run).
880
- with("doit").yields("nope\n", nil).returns(response)
865
+ executor.expects(:run)
866
+ .with("doit").yields("nope\n", nil).returns(response)
881
867
  end
882
868
 
883
869
  # rubocop:disable Metrics/MethodLength
@@ -931,13 +917,12 @@ MSG
931
917
  # rubocop:enable Metrics/MethodLength
932
918
 
933
919
  describe "when a non-zero exit code is returned" do
934
-
935
920
  common_failed_command_specs
936
921
 
937
922
  it "raises a WinrmFailed exception" do
938
- err = proc {
923
+ err = proc do
939
924
  connection.execute("doit")
940
- }.must_raise Kitchen::Transport::WinrmFailed
925
+ end.must_raise Kitchen::Transport::WinrmFailed
941
926
  err.message.must_equal "WinRM exited (1) for command: [doit]"
942
927
  end
943
928
 
@@ -952,7 +937,6 @@ MSG
952
937
  end
953
938
 
954
939
  describe "for a nil command" do
955
-
956
940
  it "does not log on debug" do
957
941
  executor.expects(:open).never
958
942
  connection.execute(nil)
@@ -968,14 +952,13 @@ MSG
968
952
  HTTPClient::KeepAliveDisconnected, HTTPClient::ConnectTimeoutError
969
953
  ].each do |klass|
970
954
  describe "raising #{klass}" do
971
-
972
955
  before do
973
956
  k = if klass == ::WinRM::WinRMHTTPTransportError
974
957
  # this exception takes 2 args in its constructor, which is not stock
975
- klass.new("dang", 200)
976
- else
977
- klass
978
- end
958
+ klass.new("dang", 200)
959
+ else
960
+ klass
961
+ end
979
962
 
980
963
  options[:connection_retries] = 3
981
964
  options[:connection_retry_sleep] = 7
@@ -990,7 +973,6 @@ MSG
990
973
  end
991
974
 
992
975
  describe "#login_command" do
993
-
994
976
  let(:login_command) { connection.login_command }
995
977
  let(:args) { login_command.arguments.join(" ") }
996
978
  let(:exec_args) { login_command.exec_args }
@@ -1000,7 +982,6 @@ MSG
1000
982
  end
1001
983
 
1002
984
  describe "for Mac-based workstations" do
1003
-
1004
985
  before do
1005
986
  RbConfig::CONFIG.stubs(:[]).with("host_os").returns("darwin14")
1006
987
  end
@@ -1058,7 +1039,6 @@ MSG
1058
1039
  end
1059
1040
 
1060
1041
  describe "for Windows-based workstations" do
1061
-
1062
1042
  before do
1063
1043
  RbConfig::CONFIG.stubs(:[]).with("host_os").returns("mingw32")
1064
1044
  end
@@ -1114,7 +1094,6 @@ MSG
1114
1094
  end
1115
1095
 
1116
1096
  describe "for Linux-based workstations" do
1117
-
1118
1097
  before do
1119
1098
  RbConfig::CONFIG.stubs(:[]).with("host_os").returns("linux-gnu")
1120
1099
  end
@@ -1144,7 +1123,6 @@ MSG
1144
1123
  end
1145
1124
 
1146
1125
  describe "for unknown workstation platforms" do
1147
-
1148
1126
  before do
1149
1127
  RbConfig::CONFIG.stubs(:[]).with("host_os").returns("cray")
1150
1128
  end
@@ -1158,12 +1136,11 @@ MSG
1158
1136
  end
1159
1137
 
1160
1138
  describe "#upload" do
1161
-
1162
1139
  before do
1163
1140
  winrm_session.stubs(:shell).with(:powershell).returns(executor)
1164
1141
 
1165
- WinRM::FS::Core::FileTransporter.stubs(:new).
1166
- with(executor).returns(transporter)
1142
+ WinRM::FS::Core::FileTransporter.stubs(:new)
1143
+ .with(executor).returns(transporter)
1167
1144
  transporter.stubs(:upload)
1168
1145
  end
1169
1146
 
@@ -1171,8 +1148,8 @@ MSG
1171
1148
  it "builds a Winrm::FileTransporter" do
1172
1149
  WinRM::FS::Core::FileTransporter.unstub(:new)
1173
1150
 
1174
- WinRM::FS::Core::FileTransporter.expects(:new).
1175
- with(executor).returns(transporter)
1151
+ WinRM::FS::Core::FileTransporter.expects(:new)
1152
+ .with(executor).returns(transporter)
1176
1153
 
1177
1154
  upload
1178
1155
  end
@@ -1180,8 +1157,8 @@ MSG
1180
1157
  it "reuses the Winrm::FileTransporter" do
1181
1158
  WinRM::FS::Core::FileTransporter.unstub(:new)
1182
1159
 
1183
- WinRM::FS::Core::FileTransporter.expects(:new).
1184
- with(executor).returns(transporter).once
1160
+ WinRM::FS::Core::FileTransporter.expects(:new)
1161
+ .with(executor).returns(transporter).once
1185
1162
 
1186
1163
  upload
1187
1164
  upload
@@ -1190,18 +1167,16 @@ MSG
1190
1167
  end
1191
1168
 
1192
1169
  describe "for a file" do
1193
-
1194
1170
  def upload # execute every time, not lazily once
1195
- connection.upload("/tmp/file.txt", "C:\\dest")
1171
+ connection.upload("/tmp/file.txt", 'C:\\dest')
1196
1172
  end
1197
1173
 
1198
1174
  common_specs_for_upload
1199
1175
  end
1200
1176
 
1201
1177
  describe "for a collection of files" do
1202
-
1203
1178
  def upload # execute every time, not lazily once
1204
- connection.upload(%W[/tmp/file1.txt /tmp/file2.txt], "C:\\dest")
1179
+ connection.upload(%w{/tmp/file1.txt /tmp/file2.txt}, 'C:\\dest')
1205
1180
  end
1206
1181
 
1207
1182
  common_specs_for_upload
@@ -1209,24 +1184,22 @@ MSG
1209
1184
  end
1210
1185
 
1211
1186
  describe "#wait_until_ready" do
1212
-
1213
1187
  before do
1214
1188
  winrm_session.stubs(:shell).with(:powershell).returns(executor)
1215
1189
  options[:max_wait_until_ready] = 300
1216
1190
  end
1217
1191
 
1218
1192
  describe "when connection is successful" do
1219
-
1220
1193
  let(:response) do
1221
1194
  o = WinRM::Output.new
1222
1195
  o.exitcode = 0
1223
- o << { :stdout => "[WinRM] Established\r\n" }
1196
+ o << { stdout: "[WinRM] Established\r\n" }
1224
1197
  o
1225
1198
  end
1226
1199
 
1227
1200
  before do
1228
- executor.expects(:run).
1229
- with("Write-Host '[WinRM] Established\n'").returns(response)
1201
+ executor.expects(:run)
1202
+ .with("Write-Host '[WinRM] Established\n'").returns(response)
1230
1203
  end
1231
1204
 
1232
1205
  it "executes an empty command string to ensure working" do
@@ -1235,23 +1208,22 @@ MSG
1235
1208
  end
1236
1209
 
1237
1210
  describe "when connection suceeds but command fails, sad panda" do
1238
-
1239
1211
  let(:response) do
1240
1212
  o = WinRM::Output.new
1241
1213
  o.exitcode = 42
1242
- o << { :stderr => "Ah crap.\r\n" }
1214
+ o << { stderr: "Ah crap.\r\n" }
1243
1215
  o
1244
1216
  end
1245
1217
 
1246
1218
  before do
1247
- executor.expects(:run).
1248
- with("Write-Host '[WinRM] Established\n'").returns(response)
1219
+ executor.expects(:run)
1220
+ .with("Write-Host '[WinRM] Established\n'").returns(response)
1249
1221
  end
1250
1222
 
1251
1223
  it "executes an empty command string to ensure working" do
1252
- err = proc {
1224
+ err = proc do
1253
1225
  connection.wait_until_ready
1254
- }.must_raise Kitchen::Transport::WinrmFailed
1226
+ end.must_raise Kitchen::Transport::WinrmFailed
1255
1227
  err.message.must_equal "WinRM exited (42) for command: " \
1256
1228
  "[Write-Host '[WinRM] Established\n']"
1257
1229
  end
@@ -1269,24 +1241,24 @@ MSG
1269
1241
  end
1270
1242
 
1271
1243
  def debug_output(output)
1272
- regexp = %r{^D, .* DEBUG -- : }
1273
- output.lines.grep(%r{^D, .* DEBUG -- : }).map { |l| l.sub(regexp, "") }.join
1244
+ regexp = /^D, .* DEBUG -- : /
1245
+ output.lines.grep(/^D, .* DEBUG -- : /).map { |l| l.sub(regexp, "") }.join
1274
1246
  end
1275
1247
 
1276
1248
  def debug_line(msg)
1277
- %r{^D, .* : #{Regexp.escape(msg)}$}
1249
+ /^D, .* : #{Regexp.escape(msg)}$/
1278
1250
  end
1279
1251
 
1280
1252
  def debug_line_with(msg)
1281
- %r{^D, .* : #{Regexp.escape(msg)}}
1253
+ /^D, .* : #{Regexp.escape(msg)}/
1282
1254
  end
1283
1255
 
1284
1256
  def info_line(msg)
1285
- %r{^I, .* : #{Regexp.escape(msg)}$}
1257
+ /^I, .* : #{Regexp.escape(msg)}$/
1286
1258
  end
1287
1259
 
1288
1260
  def info_line_with(msg)
1289
- %r{^I, .* : #{Regexp.escape(msg)}}
1261
+ /^I, .* : #{Regexp.escape(msg)}/
1290
1262
  end
1291
1263
 
1292
1264
  def regexify(string)
@@ -1294,10 +1266,10 @@ MSG
1294
1266
  end
1295
1267
 
1296
1268
  def warn_line(msg)
1297
- %r{^W, .* : #{Regexp.escape(msg)}$}
1269
+ /^W, .* : #{Regexp.escape(msg)}$/
1298
1270
  end
1299
1271
 
1300
1272
  def warn_line_with(msg)
1301
- %r{^W, .* : #{Regexp.escape(msg)}}
1273
+ /^W, .* : #{Regexp.escape(msg)}/
1302
1274
  end
1303
1275
  end