rush2 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,35 +17,35 @@ describe Rush::FindBy do
17
17
  end
18
18
 
19
19
  it "compare_or_match exact match success" do
20
- @list.compare_or_match('1', '1').should == true
20
+ expect(@list.compare_or_match('1', '1')).to eq true
21
21
  end
22
22
 
23
23
  it "compare_or_match exact match failure" do
24
- @list.compare_or_match('1', '2').should == false
24
+ expect(@list.compare_or_match('1', '2')).to eq false
25
25
  end
26
26
 
27
27
  it "compare_or_match regexp match success" do
28
- @list.compare_or_match('123', /2/).should == true
28
+ expect(@list.compare_or_match('123', /2/)).to eq true
29
29
  end
30
30
 
31
31
  it "compare_or_match regexp match failure" do
32
- @list.compare_or_match('123', /x/).should == false
32
+ expect(@list.compare_or_match('123', /x/)).to eq false
33
33
  end
34
34
 
35
35
  it "find_by_ extact match" do
36
- @list.find_by_bar('two').should == @two
36
+ expect(@list.find_by_bar('two')).to eq @two
37
37
  end
38
38
 
39
39
  it "find_by_ regexp match" do
40
- @list.find_by_bar(/.hree/).should == @three
40
+ expect(@list.find_by_bar(/.hree/)).to eq @three
41
41
  end
42
42
 
43
43
  it "find_all_by_ exact match" do
44
- @list.find_all_by_bar('one').should == [ @one ]
44
+ expect(@list.find_all_by_bar('one')).to eq [ @one ]
45
45
  end
46
46
 
47
47
  it "find_all_by_ regexp match" do
48
- @list.find_all_by_bar(/^...$/).should == [ @one, @two ]
48
+ expect(@list.find_all_by_bar(/^...$/)).to eq [ @one, @two ]
49
49
  end
50
50
 
51
51
  it "find_by_ with field not recognized by objects raises no errors" do
@@ -53,6 +53,6 @@ describe Rush::FindBy do
53
53
  end
54
54
 
55
55
  it "raises NoMethodError for things other than find_by" do
56
- lambda { @list.does_not_exist }.should raise_error(NoMethodError)
56
+ expect { @list.does_not_exist }.to raise_error(NoMethodError)
57
57
  end
58
58
  end
@@ -6,14 +6,14 @@ describe Fixnum do
6
6
  end
7
7
 
8
8
  it "counts kb" do
9
- @num.kb.should == 2*1024
9
+ expect(@num.kb).to eq 2*1024
10
10
  end
11
11
 
12
12
  it "counts mb" do
13
- @num.mb.should == 2*1024*1024
13
+ expect(@num.mb).to eq 2*1024*1024
14
14
  end
15
15
 
16
16
  it "counts gb" do
17
- @num.gb.should == 2*1024*1024*1024
17
+ expect(@num.gb).to eq 2*1024*1024*1024
18
18
  end
19
19
  end
@@ -13,264 +13,262 @@ describe Rush::Connection::Local do
13
13
  end
14
14
 
15
15
  it "receive -> write_file(file, contents)" do
16
- @con.should_receive(:write_file).with('file', 'contents')
16
+ expect(@con).to receive(:write_file).with('file', 'contents')
17
17
  @con.receive(:action => 'write_file', :full_path => 'file', :payload => 'contents')
18
18
  end
19
19
 
20
20
  it "receive -> append_to_file(file, contents)" do
21
- @con.should_receive(:append_to_file).with('file', 'contents')
21
+ expect(@con).to receive(:append_to_file).with('file', 'contents')
22
22
  @con.receive(:action => 'append_to_file', :full_path => 'file', :payload => 'contents')
23
23
  end
24
24
 
25
25
  it "receive -> file_contents(file)" do
26
- @con.should_receive(:file_contents).with('file').and_return('the contents')
27
- @con.receive(:action => 'file_contents', :full_path => 'file').should == 'the contents'
26
+ expect(@con).to receive(:file_contents).with('file').and_return('the contents')
27
+ expect(@con.receive(:action => 'file_contents', :full_path => 'file')).to eq 'the contents'
28
28
  end
29
29
 
30
30
  it "receive -> destroy(file or dir)" do
31
- @con.should_receive(:destroy).with('file')
31
+ expect(@con).to receive(:destroy).with('file')
32
32
  @con.receive(:action => 'destroy', :full_path => 'file')
33
33
  end
34
34
 
35
35
  it "receive -> purge(dir)" do
36
- @con.should_receive(:purge).with('dir')
36
+ expect(@con).to receive(:purge).with('dir')
37
37
  @con.receive(:action => 'purge', :full_path => 'dir')
38
38
  end
39
39
 
40
40
  it "receive -> create_dir(path)" do
41
- @con.should_receive(:create_dir).with('dir')
41
+ expect(@con).to receive(:create_dir).with('dir')
42
42
  @con.receive(:action => 'create_dir', :full_path => 'dir')
43
43
  end
44
44
 
45
45
  it "receive -> rename(path, name, new_name)" do
46
- @con.should_receive(:rename).with('path', 'name', 'new_name')
46
+ expect(@con).to receive(:rename).with('path', 'name', 'new_name')
47
47
  @con.receive(:action => 'rename', :path => 'path', :name => 'name', :new_name => 'new_name')
48
48
  end
49
49
 
50
50
  it "receive -> copy(src, dst)" do
51
- @con.should_receive(:copy).with('src', 'dst')
51
+ expect(@con).to receive(:copy).with('src', 'dst')
52
52
  @con.receive(:action => 'copy', :src => 'src', :dst => 'dst')
53
53
  end
54
54
 
55
55
  it "receive -> read_archive(full_path)" do
56
- @con.should_receive(:read_archive).with('full_path').and_return('archive data')
57
- @con.receive(:action => 'read_archive', :full_path => 'full_path').should == 'archive data'
56
+ expect(@con).to receive(:read_archive).with('full_path').and_return('archive data')
57
+ expect(@con.receive(:action => 'read_archive', :full_path => 'full_path')).to eq 'archive data'
58
58
  end
59
59
 
60
60
  it "receive -> write_archive(archive, dir)" do
61
- @con.should_receive(:write_archive).with('archive', 'dir')
61
+ expect(@con).to receive(:write_archive).with('archive', 'dir')
62
62
  @con.receive(:action => 'write_archive', :dir => 'dir', :payload => 'archive')
63
63
  end
64
64
 
65
65
  it "receive -> index(base_path, glob)" do
66
- @con.should_receive(:index).with('base_path', '*').and_return(%w(1 2))
67
- @con.receive(:action => 'index', :base_path => 'base_path', :glob => '*').should == "1\n2\n"
66
+ expect(@con).to receive(:index).with('base_path', '*').and_return(%w(1 2))
67
+ expect(@con.receive(:action => 'index', :base_path => 'base_path', :glob => '*')).to eq "1\n2\n"
68
68
  end
69
69
 
70
70
  it "receive -> stat(full_path)" do
71
- @con.should_receive(:stat).with('full_path').and_return(1 => 2)
72
- @con.receive(:action => 'stat', :full_path => 'full_path').should == YAML.dump(1 => 2)
71
+ expect(@con).to receive(:stat).with('full_path').and_return(1 => 2)
72
+ expect(@con.receive(:action => 'stat', :full_path => 'full_path')).to eq YAML.dump(1 => 2)
73
73
  end
74
74
 
75
75
  it "receive -> set_access(full_path, user, group, permissions)" do
76
76
  access = double("access")
77
- Rush::Access.should_receive(:from_hash).with(:action => 'set_access', :full_path => 'full_path', :user => 'joe').and_return(access)
77
+ expect(Rush::Access).to receive(:from_hash).with(:action => 'set_access', :full_path => 'full_path', :user => 'joe').and_return(access)
78
78
 
79
- @con.should_receive(:set_access).with('full_path', access)
79
+ expect(@con).to receive(:set_access).with('full_path', access)
80
80
  @con.receive(:action => 'set_access', :full_path => 'full_path', :user => 'joe')
81
81
  end
82
82
 
83
83
  it "receive -> size(full_path)" do
84
- @con.should_receive(:size).with('full_path').and_return("1024")
85
- @con.receive(:action => 'size', :full_path => 'full_path').should == "1024"
84
+ expect(@con).to receive(:size).with('full_path').and_return("1024")
85
+ expect(@con.receive(:action => 'size', :full_path => 'full_path')).to eq "1024"
86
86
  end
87
87
 
88
88
  it "receive -> chown(full_path, user, group, options)" do
89
89
  options = { noop: true }
90
- @con.should_receive(:chown).with('full_path', 'username', 'groupname', options )
90
+ expect(@con).to receive(:chown).with('full_path', 'username', 'groupname', options )
91
91
  @con.receive(:action => 'chown', :full_path => 'full_path', user: 'username', group: 'groupname', options: options)
92
92
  end
93
93
 
94
94
  it "receive -> processes" do
95
- @con.should_receive(:processes).with().and_return([ { :pid => 1 } ])
96
- @con.receive(:action => 'processes').should == YAML.dump([ { :pid => 1 } ])
95
+ expect(@con).to receive(:processes).with(no_args).and_return([ { :pid => 1 } ])
96
+ expect(@con.receive(:action => 'processes')).to eq YAML.dump([ { :pid => 1 } ])
97
97
  end
98
98
 
99
99
  it "receive -> process_alive" do
100
- @con.should_receive(:process_alive).with(123).and_return(true)
101
- @con.receive(:action => 'process_alive', :pid => 123).should == '1'
100
+ expect(@con).to receive(:process_alive).with(123).and_return(true)
101
+ expect(@con.receive(:action => 'process_alive', :pid => 123)).to eq '1'
102
102
  end
103
103
 
104
104
  it "receive -> kill_process" do
105
- @con.should_receive(:kill_process).with(123, :wait => 10).and_return(true)
105
+ expect(@con).to receive(:kill_process).with(123, :wait => 10).and_return(true)
106
106
  @con.receive(:action => 'kill_process', :pid => '123', :payload => YAML.dump(:wait => 10))
107
107
  end
108
108
 
109
109
  it "receive -> bash (reset environment)" do
110
- @con.should_receive(:bash).with('cmd', 'user', false, true).and_return('output')
111
- @con.receive(:action => 'bash', :payload => 'cmd', :user => 'user', :background => 'false', :reset_environment => 'true').should == 'output'
110
+ expect(@con).to receive(:bash).with('cmd', 'user', false, true).and_return('output')
111
+ expect(@con.receive(:action => 'bash', :payload => 'cmd', :user => 'user', :background => 'false', :reset_environment => 'true')).to eq 'output'
112
112
  end
113
113
 
114
114
  it "receive -> bash (foreground)" do
115
- @con.should_receive(:bash).with('cmd', 'user', false, false).and_return('output')
116
- @con.receive(:action => 'bash', :payload => 'cmd', :user => 'user', :background => 'false').should == 'output'
115
+ expect(@con).to receive(:bash).with('cmd', 'user', false, false).and_return('output')
116
+ expect(@con.receive(:action => 'bash', :payload => 'cmd', :user => 'user', :background => 'false')).to eq 'output'
117
117
  end
118
118
 
119
119
  it "receive -> bash (background)" do
120
- @con.should_receive(:bash).with('cmd', 'user', true, false).and_return('output')
121
- @con.receive(:action => 'bash', :payload => 'cmd', :user => 'user', :background => 'true').should == 'output'
120
+ expect(@con).to receive(:bash).with('cmd', 'user', true, false).and_return('output')
121
+ expect(@con.receive(:action => 'bash', :payload => 'cmd', :user => 'user', :background => 'true')).to eq 'output'
122
122
  end
123
123
 
124
124
  it "receive -> unknown action exception" do
125
- lambda { @con.receive(:action => 'does_not_exist') }.should raise_error(Rush::Connection::Local::UnknownAction)
125
+ expect { @con.receive(:action => 'does_not_exist') }.to raise_error(Rush::Connection::Local::UnknownAction)
126
126
  end
127
127
 
128
128
  it "write_file writes contents to a file" do
129
129
  fname = "#{@sandbox_dir}/a_file"
130
130
  data = "some data"
131
131
  @con.write_file(fname, data)
132
- File.read(fname).should == data
132
+ expect(File.read(fname)).to eq data
133
133
  end
134
134
 
135
135
  it "append_to_file appends contents to a file" do
136
136
  fname = "#{@sandbox_dir}/a_file"
137
137
  system "echo line1 > #{fname}"
138
138
  @con.append_to_file(fname, 'line2')
139
- File.read(fname).should == "line1\nline2"
139
+ expect(File.read(fname)).to eq "line1\nline2"
140
140
  end
141
141
 
142
142
  it "file_contents reads a file's contents" do
143
143
  fname = "#{@sandbox_dir}/a_file"
144
144
  system "echo stuff > #{fname}"
145
- @con.file_contents(fname).should == "stuff\n"
145
+ expect(@con.file_contents(fname)).to eq "stuff\n"
146
146
  end
147
147
 
148
148
  it "file_contents raises DoesNotExist if the file does not exist" do
149
149
  fname = "#{@sandbox_dir}/does_not_exist"
150
- lambda { @con.file_contents(fname) }.should raise_error(Rush::DoesNotExist, fname)
150
+ expect { @con.file_contents(fname) }.to raise_error(Rush::DoesNotExist, fname)
151
151
  end
152
152
 
153
153
  it "destroy to destroy a file or dir" do
154
154
  fname = "#{@sandbox_dir}/delete_me"
155
155
  system "touch #{fname}"
156
156
  @con.destroy(fname)
157
- File.exists?(fname).should be_false
157
+ expect(File.exists?(fname)).to eq false
158
158
  end
159
159
 
160
160
  it "purge to purge a dir" do
161
161
  system "cd #{@sandbox_dir}; touch {1,2}; mkdir 3; touch 3/4"
162
162
  @con.purge(@sandbox_dir)
163
- File.exists?(@sandbox_dir).should be_true
164
- Dir.glob("#{@sandbox_dir}/*").should == []
163
+ expect(File.exists?(@sandbox_dir)).to eq true
164
+ expect(Dir.glob("#{@sandbox_dir}/*")).to eq([])
165
165
  end
166
166
 
167
167
  it "purge kills hidden (dotfile) entries too" do
168
168
  system "cd #{@sandbox_dir}; touch .killme"
169
169
  @con.purge(@sandbox_dir)
170
- File.exists?(@sandbox_dir).should be_true
171
- `cd #{@sandbox_dir}; ls -lA | grep -v total | wc -l`.to_i.should == 0
170
+ expect(File.exist?(@sandbox_dir)).to eq true
171
+ expect(`cd #{@sandbox_dir}; ls -lA | grep -v total | wc -l`.to_i).to eq 0
172
172
  end
173
173
 
174
174
  it "create_dir creates a directory" do
175
175
  fname = "#{@sandbox_dir}/a/b/c/"
176
176
  @con.create_dir(fname)
177
- File.directory?(fname).should be_true
177
+ expect(File.directory?(fname)).to eq true
178
178
  end
179
179
 
180
180
  it "rename to rename entries within a dir" do
181
181
  system "touch #{@sandbox_dir}/a"
182
182
  @con.rename(@sandbox_dir, 'a', 'b')
183
- File.exists?("#{@sandbox_dir}/a").should be_false
184
- File.exists?("#{@sandbox_dir}/b").should be_true
183
+ expect(File.exists?("#{@sandbox_dir}/a")).to eq false
184
+ expect(File.exists?("#{@sandbox_dir}/b")).to eq true
185
185
  end
186
186
 
187
187
  it "copy to copy an entry to another dir on the same box" do
188
188
  system "mkdir #{@sandbox_dir}/subdir"
189
189
  system "touch #{@sandbox_dir}/a"
190
190
  @con.copy("#{@sandbox_dir}/a", "#{@sandbox_dir}/subdir")
191
- File.exists?("#{@sandbox_dir}/a").should be_true
192
- File.exists?("#{@sandbox_dir}/subdir/a").should be_true
191
+ expect(File.exists?("#{@sandbox_dir}/a")).to eq true
192
+ expect(File.exists?("#{@sandbox_dir}/subdir/a")).to eq true
193
193
  end
194
194
 
195
195
  it "copy raises DoesNotExist with source path if it doesn't exist or otherwise can't be accessed" do
196
- lambda { @con.copy('/does/not/exist', '/tmp') }.should raise_error(Rush::DoesNotExist, '/does/not/exist')
196
+ expect { @con.copy('/does/not/exist', '/tmp') }.to raise_error(Rush::DoesNotExist, '/does/not/exist')
197
197
  end
198
198
 
199
199
  it "copy raises DoesNotExist with destination path if it can't access the destination" do
200
- lambda { @con.copy('/tmp', '/does/not/exist') }.should raise_error(Rush::DoesNotExist, '/does/not')
200
+ expect { @con.copy('/tmp', '/does/not/exist') }.to raise_error(Rush::DoesNotExist, '/does/not')
201
201
  end
202
202
 
203
203
  it "read_archive to pull an archive of a dir into a byte stream" do
204
204
  system "touch #{@sandbox_dir}/a"
205
- @con.read_archive(@sandbox_dir).size.should > 50
205
+ expect(@con.read_archive(@sandbox_dir).size).to be > 50
206
206
  end
207
207
 
208
208
  it "read_archive works for paths with spaces" do
209
209
  system "mkdir -p #{@sandbox_dir}/with\\ space; touch #{@sandbox_dir}/with\\ space/a"
210
- @con.read_archive("#{@sandbox_dir}/with space").size.should > 50
210
+ expect(@con.read_archive("#{@sandbox_dir}/with space").size).to be > 50
211
211
  end
212
212
 
213
213
  it "write_archive to turn a byte stream into a dir" do
214
214
  system "cd #{@sandbox_dir}; mkdir -p a; touch a/b; tar cf xfer.tar a; mkdir dst"
215
215
  archive = File.read("#{@sandbox_dir}/xfer.tar")
216
216
  @con.write_archive(archive, "#{@sandbox_dir}/dst")
217
- File.directory?("#{@sandbox_dir}/dst/a").should be_true
218
- File.exists?("#{@sandbox_dir}/dst/a/b").should be_true
217
+ expect(File.directory?("#{@sandbox_dir}/dst/a")).to eq true
218
+ expect(File.exist?("#{@sandbox_dir}/dst/a/b")).to eq true
219
219
  end
220
220
 
221
221
  it "write_archive works for paths with spaces" do
222
222
  system "cd #{@sandbox_dir}; mkdir -p a; touch a/b; tar cf xfer.tar a; mkdir with\\ space"
223
223
  archive = File.read("#{@sandbox_dir}/xfer.tar")
224
224
  @con.write_archive(archive, "#{@sandbox_dir}/with space")
225
- File.directory?("#{@sandbox_dir}/with space/a").should be_true
226
- File.exists?("#{@sandbox_dir}/with space/a/b").should be_true
225
+ expect(File.directory?("#{@sandbox_dir}/with space/a")).to eq true
226
+ expect(File.exists?("#{@sandbox_dir}/with space/a/b")).to eq true
227
227
  end
228
228
 
229
229
  it "index fetches list of all files and dirs in a dir when pattern is empty" do
230
230
  system "cd #{@sandbox_dir}; mkdir dir; touch file"
231
- @con.index(@sandbox_dir, '').should == [ 'dir/', 'file' ]
231
+ expect(@con.index(@sandbox_dir, '')).to eq([ 'dir/', 'file' ])
232
232
  end
233
233
 
234
234
  it "index fetches only files with a certain extension with a flat pattern, *.rb" do
235
235
  system "cd #{@sandbox_dir}; touch a.rb; touch b.txt"
236
- @con.index(@sandbox_dir, '*.rb').should == [ 'a.rb' ]
236
+ expect(@con.index(@sandbox_dir, '*.rb')).to eq [ 'a.rb' ]
237
237
  end
238
238
 
239
239
  it "index raises DoesNotExist when the base path is invalid" do
240
- lambda { @con.index('/does/not/exist', '*') }.should raise_error(Rush::DoesNotExist, '/does/not/exist')
240
+ expect { @con.index('/does/not/exist', '*') }.to raise_error(Rush::DoesNotExist, '/does/not/exist')
241
241
  end
242
242
 
243
243
  it "stat gives file stats like size and timestamps" do
244
- @con.stat(@sandbox_dir).should have_key(:ctime)
245
- @con.stat(@sandbox_dir).should have_key(:size)
244
+ expect(@con.stat(@sandbox_dir)).to have_key(:ctime)
245
+ expect(@con.stat(@sandbox_dir)).to have_key(:size)
246
246
  end
247
247
 
248
248
  it "stat fetches the octal permissions" do
249
- @con.stat(@sandbox_dir)[:mode].should be_kind_of(Fixnum)
249
+ expect(@con.stat(@sandbox_dir)[:mode]).to be_kind_of(Fixnum)
250
250
  end
251
251
 
252
252
  it "stat raises DoesNotExist if the entry does not exist" do
253
253
  fname = "#{@sandbox_dir}/does_not_exist"
254
- lambda { @con.stat(fname) }.should raise_error(Rush::DoesNotExist, fname)
254
+ expect { @con.stat(fname) }.to raise_error(Rush::DoesNotExist, fname)
255
255
  end
256
256
 
257
257
  it "set_access invokes the access object" do
258
258
  access = double("access")
259
- access.should_receive(:apply).with('/some/path')
259
+ expect(access).to receive(:apply).with('/some/path')
260
260
  @con.set_access('/some/path', access)
261
261
  end
262
262
 
263
- it "chown should change the ownership of a file"
264
-
265
- if !RUBY_PLATFORM.match(/darwin/) # doesn't work on OS X 'cause du switches are different
263
+ unless RUBY_PLATFORM.match(/darwin/) # doesn't work on OS X 'cause du switches are different
266
264
  it "size gives size of a directory and all its contents recursively" do
267
265
  system "mkdir -p #{@sandbox_dir}/a/b/; echo 1234 > #{@sandbox_dir}/a/b/c"
268
- @con.size(@sandbox_dir).should == (4096*3 + 5)
266
+ expect(@con.size(@sandbox_dir)).to eq (4096*3 + 5)
269
267
  end
270
268
  end
271
269
 
272
270
  it "parses ps output on os x" do
273
- @con.parse_ps("21712 501 21711 1236 0 /usr/bin/vi somefile.rb").should == {
271
+ expect(@con.parse_ps("21712 501 21711 1236 0 /usr/bin/vi somefile.rb")).to eq({
274
272
  :pid => "21712",
275
273
  :uid => "501",
276
274
  :parent_pid => 21711,
@@ -278,67 +276,67 @@ describe Rush::Connection::Local do
278
276
  :cpu => 0,
279
277
  :command => '/usr/bin/vi',
280
278
  :cmdline => '/usr/bin/vi somefile.rb',
281
- }
279
+ })
282
280
  end
283
281
 
284
282
  it "gets the list of processes on os x via the ps command" do
285
- @con.should_receive(:os_x_raw_ps).and_return <<EOPS
283
+ expect(@con).to receive(:os_x_raw_ps).and_return <<EOPS
286
284
  PID UID PPID RSS CPU COMMAND
287
285
  1 0 1 1111 0 cmd1 args
288
286
  2 501 1 222 1 cmd2
289
287
  EOPS
290
- @con.os_x_processes.should == [
288
+ expect(@con.os_x_processes).to eq [
291
289
  { :pid => "1", :uid => "0", :parent_pid => 1, :mem => 1111, :cpu => 0, :command => "cmd1", :cmdline => "cmd1 args" },
292
290
  { :pid => "2", :uid => "501", :parent_pid => 1, :mem => 222, :cpu => 1, :command => "cmd2", :cmdline => "cmd2" },
293
291
  ]
294
292
  end
295
293
 
296
294
  it "the current process should be alive" do
297
- @con.process_alive(Process.pid).should be_true
295
+ expect(@con.process_alive(Process.pid)).to eq true
298
296
  end
299
297
 
300
298
  it "a made-up process should not be alive" do
301
- @con.process_alive(99999).should be_false
299
+ expect(@con.process_alive(99999)).to eq false
302
300
  end
303
301
 
304
302
  it "kills a process by pid sending a TERM" do
305
- @con.stub(:process_alive).and_return(false)
306
- ::Process.should_receive(:kill).with('TERM', 123).once
303
+ allow(@con).to receive(:process_alive).and_return(false)
304
+ expect(::Process).to receive(:kill).with('TERM', 123).once
307
305
  @con.kill_process(123)
308
306
  end
309
307
 
310
308
  it "kills a process by pid sending a KILL signal if TERM doesn't work" do
311
- @con.stub(:process_alive).and_return(true)
312
- ::Process.should_receive(:kill).with('TERM', 123).at_least(:twice)
313
- ::Process.should_receive(:kill).with('KILL', 123)
309
+ allow(@con).to receive(:process_alive).and_return(true)
310
+ expect(::Process).to receive(:kill).with('TERM', 123).at_least(:twice)
311
+ expect(::Process).to receive(:kill).with('KILL', 123)
314
312
  @con.kill_process(123)
315
313
  end
316
314
 
317
315
  it "kills a process by pid without sending TERM if :wait is zero" do
318
- ::Process.should_not_receive(:kill).with('TERM', 123)
319
- ::Process.should_receive(:kill).with('KILL', 123)
316
+ expect(::Process).to_not receive(:kill).with('TERM', 123)
317
+ expect(::Process).to receive(:kill).with('KILL', 123)
320
318
  @con.kill_process(123, :wait => 0)
321
319
  end
322
320
 
323
321
  it "does not raise an error if the process is already dead" do
324
- ::Process.should_receive(:kill).and_raise(Errno::ESRCH)
325
- lambda { @con.kill_process(123) }.should_not raise_error
322
+ expect(::Process).to receive(:kill).and_raise(Errno::ESRCH)
323
+ expect { @con.kill_process(123) }.to_not raise_error
326
324
  end
327
325
 
328
326
  it "executes a bash command, returning stdout when successful" do
329
- @con.bash("echo test").should == "test\n"
327
+ expect(@con.bash("echo test")).to eq "test\n"
330
328
  end
331
329
 
332
330
  it "executes a bash command, raising and error (with stderr as the message) when return value is nonzero" do
333
- lambda { @con.bash("no_such_bin") }.should raise_error(Rush::BashFailed, /command not found/)
331
+ expect { @con.bash("no_such_bin") }.to raise_error(Rush::BashFailed, /command not found/)
334
332
  end
335
333
 
336
334
  it "executes a bash command as another user using sudo" do
337
- @con.bash("echo test2", ENV['USER']).should == "test2\n"
335
+ expect(@con.bash("echo test2", ENV['USER'])).to eq "test2\n"
338
336
  end
339
337
 
340
338
  it "executes a bash command in the background, returning the pid" do
341
- @con.bash("true", nil, true).should > 0
339
+ expect(@con.bash("true", nil, true)).to be > 0
342
340
  end
343
341
 
344
342
  it "ensure_tunnel to match with remote connection" do
@@ -346,20 +344,22 @@ EOPS
346
344
  end
347
345
 
348
346
  it "always returns true on alive?" do
349
- @con.should be_alive
347
+ expect(@con).to be_alive
350
348
  end
351
349
 
352
350
  it "resolves a unix uid to a user" do
353
- @con.resolve_unix_uid_to_user(0).should == "root"
354
- @con.resolve_unix_uid_to_user('0').should == "root"
351
+ expect(@con.resolve_unix_uid_to_user(0)).to eq "root"
352
+ expect(@con.resolve_unix_uid_to_user('0')).to eq "root"
355
353
  end
356
354
 
357
355
  it "returns nil if the unix uid does not exist" do
358
- @con.resolve_unix_uid_to_user(9999).should be_nil
356
+ expect(@con.resolve_unix_uid_to_user(9999)).to eq nil
359
357
  end
360
358
 
361
359
  it "iterates through a process list and resolves the unix uid for each" do
362
360
  list = [ { :uid => 0, :command => 'pureftpd' }, { :uid => 9999, :command => 'defunk' } ]
363
- @con.resolve_unix_uids(list).should == [ { :uid => 0, :user => 'root', :command => 'pureftpd' }, { :uid => 9999, :command => 'defunk', :user => nil } ]
361
+ expect(@con.resolve_unix_uids(list))
362
+ .to eq([{ :uid => 0, :user => 'root', :command => 'pureftpd' },
363
+ { :uid => 9999, :command => 'defunk', :user => nil }])
364
364
  end
365
365
  end