ridley-connectors 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 762f12e6c4e0916c5d00458a76b433770fe3d8ac
4
- data.tar.gz: a4f104fb5eb97c9c9bb16bc3204e65575938956b
3
+ metadata.gz: 7af7fa7d2548244502ecb8c58068e8942e53e050
4
+ data.tar.gz: 47f076edd626e03d1703891822e0299f5eb91ea4
5
5
  SHA512:
6
- metadata.gz: 6b7d0f5c3ae3054ea68907876e81b5de8816b8a0f691bdefbd2e59b32aed185a253a9b870149ec14d9957d015c1b29c485e6bb6ae62cd1997b423929dc467220
7
- data.tar.gz: 67aac46a68059c709d2519f69ff11391ee28ae98428c435b12ad9c00423286c24f9ac0a82916857bbb10d11df2fa962c21fd31d17e8379cd692b7ef4ce914ae3
6
+ metadata.gz: 89b29b05d062eaf1935561e31c4b07434bf2509bb9ad8a00c67247fcbf54047b25aea68d4303fa1e7e8d82fd552203e91750a6c2b6bacc591d863362f3f1d9ad
7
+ data.tar.gz: 287594f56bf8892051b1f47c79051f2cb95f760d4af28ab66a5879d59d7a7799e99ddf46b1f000ef4c2bfe2bc586e042010c04ba704f366680f9ce81175868c0
@@ -1,3 +1,9 @@
1
+ ## 2.4.0
2
+
3
+ * Fix race condition with choosing and starting the appropriate connector
4
+ * Bump required Celluloid/Celluloid-IO versions
5
+ * Silence noisy warning output into debug output
6
+
1
7
  ## 2.3.1
2
8
 
3
9
  * Fix installation problem on some Windows machines
data/Gemfile CHANGED
@@ -5,14 +5,13 @@ gemspec
5
5
  group :development do
6
6
  gem 'yard'
7
7
  gem 'spork'
8
- gem 'guard', '~> 1.8'
8
+ gem 'guard', '~> 2.0'
9
9
  gem 'guard-rspec'
10
- gem 'guard-spork', platforms: :ruby
11
- gem 'fuubar'
12
10
  end
13
11
 
14
12
  group :test do
15
13
  gem 'rspec'
16
14
  gem 'webmock'
17
15
  gem 'thor'
16
+ gem 'rake'
18
17
  end
data/Guardfile CHANGED
@@ -1,12 +1,6 @@
1
1
  notification :off
2
2
 
3
- guard 'spork' do
4
- watch('Gemfile')
5
- watch('spec/spec_helper.rb') { :rspec }
6
- watch(%r{^spec/support/.+\.rb$}) { :rspec }
7
- end
8
-
9
- guard 'rspec', cli: "--color --drb --format Fuubar", all_on_start: false, all_after_pass: false do
3
+ guard 'rspec', cmd: "bundle exec rspec --color", all_on_start: false, all_after_pass: false do
10
4
  watch(%r{^spec/unit/.+_spec\.rb$})
11
5
  watch(%r{^spec/acceptance/.+_spec\.rb$})
12
6
 
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -225,20 +225,16 @@ module Ridley
225
225
  #
226
226
  # @return [HostConnector::SSH, HostConnector::WinRM, NilClass]
227
227
  def connector_for(host, options = {})
228
- connector = options[:connector]
228
+ connector = options[:connector].to_s
229
229
 
230
230
  if !VALID_CONNECTORS.include?(connector)
231
- log.warn { "Received connector '#{connector}' is not one of #{VALID_CONNECTORS}. Checking default connectors..." }
231
+ log.debug { "Connector '#{connector}' is not one of #{VALID_CONNECTORS}. Determining connector..." }
232
232
  connector = nil
233
233
  end
234
234
 
235
- if (connector == DEFAULT_WINDOWS_CONNECTOR || connector.nil?) &&
236
- winrm.connector_port_open?(host, options)
237
- options.delete(:ssh)
235
+ if (connector == DEFAULT_WINDOWS_CONNECTOR || connector.nil?) && winrm.connector_port_open?(host, options)
238
236
  winrm
239
- elsif (connector == DEFAULT_LINUX_CONNECTOR || connector.nil?) &&
240
- ssh.connector_port_open?(host, options)
241
- options.delete(:winrm)
237
+ elsif (connector == DEFAULT_LINUX_CONNECTOR || connector.nil?) && ssh.connector_port_open?(host, options)
242
238
  ssh
243
239
  else
244
240
  nil
@@ -265,7 +261,11 @@ module Ridley
265
261
  if connector.nil?
266
262
  log.warn { "No connector ports open on '#{host}'" }
267
263
  HostConnector::Response.new(host, stderr: "No connector ports open on '#{host}'")
268
- else
264
+ elsif connector.is_a?(winrm.class)
265
+ options.delete(:ssh)
266
+ connector.send(method, host, *args, options)
267
+ elsif connector.is_a?(ssh.class)
268
+ options.delete(:winrm)
269
269
  connector.send(method, host, *args, options)
270
270
  end
271
271
  end
@@ -8,7 +8,7 @@ module Ridley
8
8
  RETRY_COUNT = 3
9
9
  CONNECTOR_PORT_ERRORS = [Errno::ETIMEDOUT,
10
10
  Timeout::Error,
11
- SocketError,
11
+ SocketError,
12
12
  Errno::ECONNREFUSED,
13
13
  Errno::EHOSTUNREACH,
14
14
  Errno::EADDRNOTAVAIL,
@@ -129,12 +129,12 @@ module Ridley
129
129
  # @param [Fixnum] port
130
130
  # the port to attempt to connect on
131
131
  # @param [Fixnum] timeout ({PORT_CHECK_TIMEOUT})
132
- #
132
+ #
133
133
  # @return [Boolean]
134
134
  def connectable?(host, port, timeout = PORT_CHECK_TIMEOUT)
135
- addr = Socket.getaddrinfo(host, nil)
135
+ addr = Socket.getaddrinfo(host, nil)
136
136
  sockaddr = Socket.pack_sockaddr_in(port, addr[0][3])
137
- socket = Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0)
137
+ socket = Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0)
138
138
  socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
139
139
 
140
140
  success = false
@@ -1,6 +1,5 @@
1
1
  module Ridley
2
2
  class NodeResource
3
-
4
3
  attr_reader :server_url
5
4
  attr_reader :validator_path
6
5
  attr_reader :validator_client
@@ -123,7 +122,7 @@ module Ridley
123
122
  # @param [String] host
124
123
  # @param [Array<String>] command_lines
125
124
  # @option options [String] :connector
126
- # a connectory type to prefer
125
+ # a connectory type to prefer
127
126
  #
128
127
  # @return [HostConnector::Response]
129
128
  def ruby_script(host, command_lines, options = {})
@@ -135,6 +134,8 @@ module Ridley
135
134
  #
136
135
  # @param [String] host
137
136
  # @param [String] command
137
+ # @option options [String] :connector
138
+ # a connectory type to prefer
138
139
  #
139
140
  # @return [HostConnector::Response]
140
141
  def run(host, command, options = {})
@@ -192,7 +193,6 @@ module Ridley
192
193
  host_commander.uninstall_chef(host, options)
193
194
  end
194
195
 
195
-
196
196
  # Update a node's Omnibus installation of Chef
197
197
  #
198
198
  # @param [String] host
@@ -1,5 +1,5 @@
1
1
  module Ridley
2
2
  module Connectors
3
- VERSION = "2.3.1"
3
+ VERSION = "2.4.0"
4
4
  end
5
5
  end
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.version = Ridley::Connectors::VERSION
18
18
  s.required_ruby_version = ">= 1.9.1"
19
19
 
20
- s.add_dependency 'celluloid', '~> 0.16.0.pre'
21
- s.add_dependency 'celluloid-io', '~> 0.16.0.pre'
20
+ s.add_dependency 'celluloid', '~> 0.16.0'
21
+ s.add_dependency 'celluloid-io', '~> 0.16.1'
22
22
  s.add_dependency 'erubis'
23
23
  s.add_dependency 'net-ssh'
24
24
  s.add_dependency 'net-ssh-gateway'
@@ -19,7 +19,7 @@ describe Ridley::BootstrapContext::Unix do
19
19
  options.delete(:sudo)
20
20
  obj = subject.new(options)
21
21
 
22
- obj.send(:sudo).should be_true
22
+ expect(obj.send(:sudo)).to be true
23
23
  end
24
24
  end
25
25
 
@@ -28,7 +28,7 @@ describe Ridley::BootstrapContext::Unix do
28
28
  options.merge!(sudo: false)
29
29
  obj = subject.new(options)
30
30
 
31
- obj.send(:sudo).should be_false
31
+ expect(obj.send(:sudo)).to be false
32
32
  end
33
33
  end
34
34
  end
@@ -40,62 +40,62 @@ describe Ridley::BootstrapContext::Unix do
40
40
 
41
41
  describe "#templates_path" do
42
42
  it "returns a pathname" do
43
- subject.templates_path.should be_a(Pathname)
43
+ expect(subject.templates_path).to be_a(Pathname)
44
44
  end
45
45
  end
46
46
 
47
47
  describe "#first_boot" do
48
48
  it "returns a string" do
49
- subject.first_boot.should be_a(String)
49
+ expect(subject.first_boot).to be_a(String)
50
50
  end
51
51
  end
52
52
 
53
53
  describe "#encrypted_data_bag_secret" do
54
54
  it "returns a string" do
55
- subject.encrypted_data_bag_secret.should be_a(String)
55
+ expect(subject.encrypted_data_bag_secret).to be_a(String)
56
56
  end
57
57
  end
58
58
 
59
59
  describe "#validation_key" do
60
60
  it "returns a string" do
61
- subject.validation_key.should be_a(String)
61
+ expect(subject.validation_key).to be_a(String)
62
62
  end
63
63
  end
64
64
 
65
65
  describe "template" do
66
66
  it "returns a string" do
67
- subject.template.should be_a(Erubis::Eruby)
67
+ expect(subject.template).to be_a(Erubis::Eruby)
68
68
  end
69
69
  end
70
70
  end
71
71
 
72
72
  describe "#boot_command" do
73
73
  it "returns a string" do
74
- subject.boot_command.should be_a(String)
74
+ expect(subject.boot_command).to be_a(String)
75
75
  end
76
76
  end
77
77
 
78
78
  describe "#chef_run" do
79
79
  it "returns a string" do
80
- subject.chef_run.should be_a(String)
80
+ expect(subject.chef_run).to be_a(String)
81
81
  end
82
82
  end
83
83
 
84
84
  describe "#chef_config" do
85
85
  it "returns a string" do
86
- subject.chef_config.should be_a(String)
86
+ expect(subject.chef_config).to be_a(String)
87
87
  end
88
88
  end
89
89
 
90
90
  describe "#default_template" do
91
91
  it "returns a string" do
92
- subject.default_template.should be_a(String)
92
+ expect(subject.default_template).to be_a(String)
93
93
  end
94
94
  end
95
95
 
96
96
  describe "#bootstrap_directory" do
97
97
  it "returns a string" do
98
- subject.bootstrap_directory.should be_a(String)
98
+ expect(subject.bootstrap_directory).to be_a(String)
99
99
  end
100
100
  end
101
101
  end
@@ -18,7 +18,7 @@ describe Ridley::BootstrapContext::Base do
18
18
  describe ":included" do
19
19
  context "when a class includes Ridley::BootstrapBinding" do
20
20
  it "should have a validate_options class method`" do
21
- subject.methods.should include(:validate_options)
21
+ expect(subject.methods).to include(:validate_options)
22
22
  end
23
23
  end
24
24
  end
@@ -21,11 +21,11 @@ describe Ridley::Client do
21
21
  subject { described_class.new(options) }
22
22
 
23
23
  it "assigns a 'ssh' attribute from the given 'ssh' option" do
24
- described_class.new(config).ssh.should eql({user: "fake", password: "password1", port: "222"})
24
+ expect(described_class.new(config).ssh).to eql({user: "fake", password: "password1", port: "222"})
25
25
  end
26
26
 
27
27
  it "assigns a 'winrm' attribute from the given 'winrm' option" do
28
- described_class.new(config).winrm.should eql({user: "fake", password: "password2", port: "5986"})
28
+ expect(described_class.new(config).winrm).to eql({user: "fake", password: "password2", port: "5986"})
29
29
  end
30
30
  end
31
31
  end
@@ -6,7 +6,7 @@ describe Ridley::CommandContext::UnixUninstall do
6
6
  describe "::new" do
7
7
  context "when skip_chef is not provided" do
8
8
  it "sets skip_chef to false" do
9
- expect(unix_uninstall.skip_chef).to be_false
9
+ expect(unix_uninstall.skip_chef).to be false
10
10
  end
11
11
  end
12
12
  end
@@ -12,7 +12,7 @@ describe Ridley::CommandContext::UnixUpdateOmnibus do
12
12
 
13
13
  context "when prerelease is not given" do
14
14
  it "prerelease is set to false" do
15
- expect(unix_update_omnibus.prerelease).to be_false
15
+ expect(unix_update_omnibus.prerelease).to be false
16
16
  end
17
17
  end
18
18
 
@@ -31,7 +31,7 @@ describe Ridley::CommandContext::UnixUpdateOmnibus do
31
31
  end
32
32
 
33
33
  it "sets prerelease" do
34
- expect(unix_update_omnibus.prerelease).to be_true
34
+ expect(unix_update_omnibus.prerelease).to be true
35
35
  end
36
36
 
37
37
  it "sets direct_url" do
@@ -12,7 +12,7 @@ describe Ridley::CommandContext::WindowsUpdateOmnibus do
12
12
 
13
13
  context "when prerelease is not given" do
14
14
  it "prerelease is set to false" do
15
- expect(windows_update_omnibus.prerelease).to be_false
15
+ expect(windows_update_omnibus.prerelease).to be false
16
16
  end
17
17
  end
18
18
 
@@ -31,7 +31,7 @@ describe Ridley::CommandContext::WindowsUpdateOmnibus do
31
31
  end
32
32
 
33
33
  it "sets prerelease" do
34
- expect(windows_update_omnibus.prerelease).to be_true
34
+ expect(windows_update_omnibus.prerelease).to be true
35
35
  end
36
36
 
37
37
  it "sets direct_url" do
@@ -12,25 +12,24 @@ describe Ridley::HostCommander do
12
12
 
13
13
  context "when communicating to a unix node" do
14
14
  before do
15
- subject.send(:winrm).stub(:port_open?).and_return(false)
16
- subject.send(:ssh).stub(:port_open?).and_return(true)
15
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { false }
16
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { true }
17
17
  end
18
18
 
19
19
  it "sends a #run message to the ssh host connector" do
20
- subject.send(:ssh).should_receive(:run).with(host, command, options)
20
+ expect(subject.send(:ssh)).to receive(:send).with(:run, host, command, options)
21
21
  subject.run(host, command, options)
22
22
  end
23
23
  end
24
24
 
25
25
  context "when communicating to a windows node" do
26
26
  before do
27
- subject.send(:winrm).stub(:port_open?).and_return(true)
28
- subject.send(:ssh).stub(:port_open?).and_return(false)
27
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { true }
28
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { false }
29
29
  end
30
30
 
31
31
  it "sends a #run message to the ssh host connector" do
32
- subject.send(:winrm).should_receive(:run).with(host, command, options)
33
-
32
+ expect(subject.send(:winrm)).to receive(:send).with(:run, host, command, options)
34
33
  subject.run(host, command, options)
35
34
  end
36
35
  end
@@ -43,12 +42,12 @@ describe Ridley::HostCommander do
43
42
 
44
43
  context "when communicating to a unix node" do
45
44
  before do
46
- subject.send(:winrm).stub(:port_open?).and_return(false)
47
- subject.send(:ssh).stub(:port_open?).and_return(true)
45
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { false }
46
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { true }
48
47
  end
49
48
 
50
49
  it "sends a #bootstrap message to the ssh host connector" do
51
- subject.send(:ssh).should_receive(:bootstrap).with(host, options)
50
+ expect(subject.send(:ssh)).to receive(:bootstrap).with(host, options)
52
51
 
53
52
  subject.bootstrap(host, options)
54
53
  end
@@ -56,12 +55,12 @@ describe Ridley::HostCommander do
56
55
 
57
56
  context "when communicating to a windows node" do
58
57
  before do
59
- subject.send(:winrm).stub(:port_open?).and_return(true)
60
- subject.send(:ssh).stub(:port_open?).and_return(false)
58
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { true }
59
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { false }
61
60
  end
62
61
 
63
62
  it "sends a #bootstrap message to the winrm host connector" do
64
- subject.send(:winrm).should_receive(:bootstrap).with(host, options)
63
+ expect(subject.send(:winrm)).to receive(:bootstrap).with(host, options)
65
64
 
66
65
  subject.bootstrap(host, options)
67
66
  end
@@ -75,12 +74,12 @@ describe Ridley::HostCommander do
75
74
 
76
75
  context "when communicating to a unix node" do
77
76
  before do
78
- subject.send(:winrm).stub(:port_open?).and_return(false)
79
- subject.send(:ssh).stub(:port_open?).and_return(true)
77
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { false }
78
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { true }
80
79
  end
81
80
 
82
81
  it "sends a #chef_client message to the ssh host connector" do
83
- subject.send(:ssh).should_receive(:chef_client).with(host, options)
82
+ expect(subject.send(:ssh)).to receive(:chef_client).with(host, options)
84
83
 
85
84
  subject.chef_client(host, options)
86
85
  end
@@ -88,12 +87,12 @@ describe Ridley::HostCommander do
88
87
 
89
88
  context "when communicating to a windows node" do
90
89
  before do
91
- subject.send(:winrm).stub(:port_open?).and_return(true)
92
- subject.send(:ssh).stub(:port_open?).and_return(false)
90
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { true }
91
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { false }
93
92
  end
94
93
 
95
94
  it "sends a #chef_client message to the ssh host connector" do
96
- subject.send(:winrm).should_receive(:chef_client).with(host, options)
95
+ expect(subject.send(:winrm)).to receive(:chef_client).with(host, options)
97
96
 
98
97
  subject.chef_client(host, options)
99
98
  end
@@ -108,12 +107,12 @@ describe Ridley::HostCommander do
108
107
 
109
108
  context "when communicating to a unix node" do
110
109
  before do
111
- subject.send(:winrm).stub(:port_open?).and_return(false)
112
- subject.send(:ssh).stub(:port_open?).and_return(true)
110
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { false }
111
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { true }
113
112
  end
114
113
 
115
114
  it "sends a #put_secret message to the ssh host connector" do
116
- subject.send(:ssh).should_receive(:put_secret).with(host, secret, options)
115
+ expect(subject.send(:ssh)).to receive(:put_secret).with(host, secret, options)
117
116
 
118
117
  subject.put_secret(host, secret, options)
119
118
  end
@@ -121,12 +120,12 @@ describe Ridley::HostCommander do
121
120
 
122
121
  context "when communicating to a windows node" do
123
122
  before do
124
- subject.send(:winrm).stub(:port_open?).and_return(true)
125
- subject.send(:ssh).stub(:port_open?).and_return(false)
123
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { true }
124
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { false }
126
125
  end
127
126
 
128
127
  it "sends a #put_secret message to the ssh host connector" do
129
- subject.send(:winrm).should_receive(:put_secret).with(host, secret, options)
128
+ expect(subject.send(:winrm)).to receive(:put_secret).with(host, secret, options)
130
129
 
131
130
  subject.put_secret(host, secret, options)
132
131
  end
@@ -141,12 +140,12 @@ describe Ridley::HostCommander do
141
140
 
142
141
  context "when communicating to a unix node" do
143
142
  before do
144
- subject.send(:winrm).stub(:port_open?).and_return(false)
145
- subject.send(:ssh).stub(:port_open?).and_return(true)
143
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { false }
144
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { true }
146
145
  end
147
146
 
148
147
  it "sends a #ruby_script message to the ssh host connector" do
149
- subject.send(:ssh).should_receive(:ruby_script).with(host, command_lines, options)
148
+ expect(subject.send(:ssh)).to receive(:ruby_script).with(host, command_lines, options)
150
149
 
151
150
  subject.ruby_script(host, command_lines, options)
152
151
  end
@@ -154,12 +153,12 @@ describe Ridley::HostCommander do
154
153
 
155
154
  context "when communicating to a windows node" do
156
155
  before do
157
- subject.send(:winrm).stub(:port_open?).and_return(true)
158
- subject.send(:ssh).stub(:port_open?).and_return(false)
156
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { true }
157
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { false }
159
158
  end
160
159
 
161
160
  it "sends a #ruby_script message to the ssh host connector" do
162
- subject.send(:winrm).should_receive(:ruby_script).with(host, command_lines, options)
161
+ expect(subject.send(:winrm)).to receive(:ruby_script).with(host, command_lines, options)
163
162
 
164
163
  subject.ruby_script(host, command_lines, options)
165
164
  end
@@ -176,7 +175,7 @@ describe Ridley::HostCommander do
176
175
 
177
176
  it "executes retry logic" do
178
177
  @times_called = 0
179
- subject.send(:winrm).should_receive(:connectable?).twice.and_return do
178
+ expect(subject.send(:winrm)).to receive(:connectable?).twice do
180
179
  @times_called += 1
181
180
  if @times_called == 1
182
181
  raise Errno::ETIMEDOUT
@@ -189,14 +188,14 @@ describe Ridley::HostCommander do
189
188
  end
190
189
  end
191
190
 
192
- it "should return winrm if winrm is open" do
193
- subject.send(:winrm).stub(:port_open?).and_return(true)
191
+ it "returns winrm if winrm is open" do
192
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { true }
194
193
  expect(subject.connector_for(host).class).to eq(Ridley::HostConnector::WinRM)
195
194
  end
196
-
197
- it "should return ssh if winrm is closed" do
198
- subject.send(:winrm).stub(:port_open?).and_return(false)
199
- subject.send(:ssh).stub(:port_open?).and_return(true)
195
+
196
+ it "returns ssh if winrm is closed" do
197
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { false }
198
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { true }
200
199
  expect(subject.connector_for(host).class).to eq(Ridley::HostConnector::SSH)
201
200
  end
202
201
 
@@ -204,13 +203,13 @@ describe Ridley::HostCommander do
204
203
  let(:connector_options) { options.merge(connector: "winrm") }
205
204
  let(:winrm) { double }
206
205
 
207
- it "should return winrm if winrm is open" do
208
- subject.send(:winrm).stub(:port_open?).and_return(true)
206
+ it "returns winrm if winrm is open" do
207
+ allow(subject.send(:winrm)).to receive(:connector_port_open?) { true }
209
208
  expect(subject.connector_for(host, options).class).to eql(Ridley::HostConnector::WinRM)
210
209
  end
211
210
 
212
- it "should return nil if winrm is closed" do
213
- subject.stub(:port_open?).and_return(false)
211
+ it "returns nil if winrm is closed" do
212
+ allow(subject).to receive(:connector_port_open?) { false }
214
213
  expect(subject.connector_for(host, connector_options)).to be_nil
215
214
  end
216
215
  end
@@ -218,15 +217,15 @@ describe Ridley::HostCommander do
218
217
  context "when a connector of ssh is given" do
219
218
  let(:connector_options) { options.merge(connector: "ssh") }
220
219
 
221
- it "should return ssh if ssh is open" do
222
- subject.send(:ssh).stub(:port_open?).and_return(true)
223
- subject.send(:winrm).should_not_receive(:port_open?)
220
+ it "returns ssh if ssh is open" do
221
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { true }
222
+ expect(subject.send(:winrm)).not_to receive(:connector_port_open?)
224
223
  expect(subject.connector_for(host, connector_options).class).to eql(Ridley::HostConnector::SSH)
225
224
  end
226
225
 
227
- it "should return nil if ssh is closed" do
228
- subject.send(:ssh).stub(:port_open?).and_return(false)
229
- subject.send(:winrm).should_not_receive(:port_open?)
226
+ it "returns nil if ssh is closed" do
227
+ allow(subject.send(:ssh)).to receive(:connector_port_open?) { false }
228
+ expect(subject.send(:winrm)).not_to receive(:connector_port_open?)
230
229
  expect(subject.connector_for(host, connector_options)).to be_nil
231
230
  end
232
231
  end
@@ -234,8 +233,8 @@ describe Ridley::HostCommander do
234
233
  context "when an unknown connector is given" do
235
234
  let(:connector_options) { options.merge(connector: "foo") }
236
235
 
237
- it "should try both connectors" do
238
- [:winrm, :ssh].each { |c| subject.send(c).should_receive(:port_open?) }
236
+ it "tries both connectors" do
237
+ [:winrm, :ssh].each { |c| expect(subject.send(c)).to receive(:connector_port_open?) }
239
238
  subject.connector_for(host, connector_options)
240
239
  end
241
240
  end
@@ -15,22 +15,26 @@ describe Ridley::HostConnector::WinRM::CommandUploader do
15
15
  let(:run_cmd_data) { { data: [{ stdout: "abc123" }] } }
16
16
  let(:command_file_name) { "my_command.bat" }
17
17
 
18
- its(:winrm) { should eq(winrm_stub) }
18
+ describe "#winrm" do
19
+ it "is equal to the given winrm web service object" do
20
+ expect(subject.winrm).to eq(winrm_stub)
21
+ end
22
+ end
19
23
 
20
24
  before do
21
- command_uploader.stub(:get_file_path).and_return("")
25
+ allow(command_uploader).to receive(:get_file_path) { "" }
22
26
  end
23
27
 
24
28
  describe "#upload" do
25
29
  let(:upload) { command_uploader.upload(command_string) }
26
30
 
27
31
  it "calls winrm to upload and convert the command" do
28
- winrm_stub.should_receive(:run_cmd).and_return(
32
+ expect(winrm_stub).to receive(:run_cmd).and_return(
29
33
  run_cmd_data,
30
34
  nil,
31
35
  run_cmd_data
32
36
  )
33
- winrm_stub.should_receive(:powershell)
37
+ expect(winrm_stub).to receive(:powershell)
34
38
 
35
39
  upload
36
40
  end
@@ -41,7 +45,7 @@ describe Ridley::HostConnector::WinRM::CommandUploader do
41
45
  let(:command) { command_uploader.command }
42
46
 
43
47
  before do
44
- command_uploader.stub command_file_name: command_file_name
48
+ allow(command_uploader).to receive(:command_file_name) { command_file_name }
45
49
  end
46
50
 
47
51
  it { should eq("cmd.exe /C #{command_file_name}") }
@@ -54,13 +58,13 @@ describe Ridley::HostConnector::WinRM::CommandUploader do
54
58
  let(:base64_file_name) { "my_base64_file" }
55
59
 
56
60
  before do
57
- command_uploader.stub command_file_name: command_file_name
58
- command_uploader.stub base64_file_name: base64_file_name
61
+ allow(command_uploader).to receive(:command_file_name) { command_file_name }
62
+ allow(command_uploader).to receive(:base64_file_name) { base64_file_name }
59
63
  end
60
64
 
61
65
  it "cleans up the windows temp dir" do
62
- winrm_stub.should_receive(:run_cmd).with("del #{base64_file_name} /F /Q")
63
- winrm_stub.should_receive(:run_cmd).with("del #{command_file_name} /F /Q")
66
+ expect(winrm_stub).to receive(:run_cmd).with("del #{base64_file_name} /F /Q")
67
+ expect(winrm_stub).to receive(:run_cmd).with("del #{command_file_name} /F /Q")
64
68
  cleanup
65
69
  end
66
70
  end
@@ -55,7 +55,7 @@ describe Ridley::HostConnector::Base do
55
55
  Socket
56
56
  .stub(:getaddrinfo)
57
57
  .with(host, nil)
58
- .and_return [["AF_INET", 0, "33.33.33.10", "33.33.33.10", 2, 2, 17],
58
+ .and_return [["AF_INET", 0, "33.33.33.10", "33.33.33.10", 2, 2, 17],
59
59
  ["AF_INET", 0, "33.33.33.10", "33.33.33.10", 2, 1, 6]]
60
60
  end
61
61
 
@@ -73,26 +73,26 @@ describe Ridley::HostConnector::Base do
73
73
 
74
74
  it "should return true when a connection is initiated" do
75
75
  ::IO.stub(:select).and_return ["an array!"]
76
-
77
- expect(subject.send(:connectable?, host, port)).to be_true
76
+
77
+ expect(subject.send(:connectable?, host, port)).to be true
78
78
  end
79
79
 
80
80
  it "should return true when a connection is initiated and an explicit nil is passed as the timeout" do
81
81
  ::IO.stub(:select).with(anything, anything, anything, Ridley::HostConnector::Base::PORT_CHECK_TIMEOUT).and_return ["an array!"]
82
-
83
- expect(subject.send(:connectable?, host, port, nil)).to be_true
82
+
83
+ expect(subject.send(:connectable?, host, port, nil)).to be true
84
84
  end
85
85
 
86
86
  it "should return false when select times out" do
87
87
  ::IO.stub(:select).and_return nil
88
88
 
89
- expect(subject.send(:connectable?, host, port)).to be_false
89
+ expect(subject.send(:connectable?, host, port)).to be false
90
90
  end
91
91
 
92
92
  it "should return true when the connection does not have to wait" do
93
93
  Socket.any_instance.stub(:connect_nonblock).and_return 0
94
-
95
- expect(subject.send(:connectable?, host, port)).to be_true
94
+
95
+ expect(subject.send(:connectable?, host, port)).to be true
96
96
  end
97
97
  end
98
98
 
@@ -113,13 +113,13 @@ describe Ridley::HostConnector::Base do
113
113
 
114
114
  context "should return false" do
115
115
  it "" do
116
- expect(subject.send(:connectable?, host, port)).to be_false
116
+ expect(subject.send(:connectable?, host, port)).to be false
117
117
  end
118
118
 
119
119
  it "when the socket close throws EBAFD" do
120
120
  Socket.any_instance.stub(:close).and_return { raise Errno::EBADF.new }
121
121
 
122
- expect(subject.send(:connectable?, host, port)).to be_false
122
+ expect(subject.send(:connectable?, host, port)).to be false
123
123
  end
124
124
  end
125
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridley-connectors
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-11 00:00:00.000000000 Z
12
+ date: 2015-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.16.0.pre
20
+ version: 0.16.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.16.0.pre
27
+ version: 0.16.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: celluloid-io
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.16.0.pre
34
+ version: 0.16.1
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.16.0.pre
41
+ version: 0.16.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: erubis
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -132,13 +132,13 @@ extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
134
  - ".gitignore"
135
- - ".ruby-version"
136
135
  - ".travis.yml"
137
136
  - CHANGELOG.md
138
137
  - Gemfile
139
138
  - Guardfile
140
139
  - LICENSE
141
140
  - README.md
141
+ - Rakefile
142
142
  - Thorfile
143
143
  - bootstrappers/unix_omnibus.erb
144
144
  - bootstrappers/windows_omnibus.erb
@@ -1 +0,0 @@
1
- 2.1.1