maid 0.5.0 → 0.6.0.alpha.1

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.
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  # Workaround for Ruby 2.1.0, remove after https://github.com/defunkt/fakefs/pull/209 is released
5
- if RUBY_VERSION == '2.1.0'
5
+ if RUBY_VERSION == '2.1.0' || RUBY_VERSION == '2.1.1'
6
6
  module FakeFS
7
7
  class Dir
8
8
  def self.entries(dirname, opts = {})
@@ -25,7 +25,7 @@ module Maid
25
25
  @home = File.expand_path('~')
26
26
  @now = Time.now
27
27
 
28
- Maid.ancestors.should include(Tools)
28
+ expect(Maid.ancestors).to include(Tools)
29
29
 
30
30
  @logger = double('Logger').as_null_object
31
31
  @maid = Maid.new(:logger => @logger)
@@ -45,24 +45,24 @@ module Maid
45
45
  FileUtils.mkdir_p(@dst_dir = '~/Destination/')
46
46
  end
47
47
 
48
- it 'should move expanded paths, passing file_options' do
48
+ it 'moves expanded paths, passing file_options' do
49
49
  @maid.move(@src_file, @dst_dir)
50
- File.exists?(@dst_dir + @file_name).should be_true
50
+ expect(File.exists?(@dst_dir + @file_name)).to be(true)
51
51
  end
52
52
 
53
- it 'should log the move' do
54
- @logger.should_receive(:info)
53
+ it 'logs the move' do
54
+ expect(@logger).to receive(:info)
55
55
  @maid.move(@src_file, @dst_dir)
56
56
  end
57
57
 
58
- it 'should handle multiple from paths' do
58
+ it 'handles multiple from paths' do
59
59
  second_src_file = @src_dir + (second_file_name = 'bar.zip')
60
60
  FileUtils.touch(second_src_file)
61
61
  src_files = [@src_file, second_src_file]
62
62
 
63
63
  @maid.move(src_files, @dst_dir)
64
- File.exist?(@dst_dir + @file_name).should be_true
65
- File.exist?(@dst_dir + second_file_name).should be_true
64
+ expect(File.exist?(@dst_dir + @file_name)).to be(true)
65
+ expect(File.exist?(@dst_dir + second_file_name)).to be(true)
66
66
  end
67
67
 
68
68
  context 'given the destination directory does not exist' do
@@ -71,8 +71,8 @@ module Maid
71
71
  end
72
72
 
73
73
  it 'does not overwrite when moving' do
74
- FileUtils.should_not_receive(:mv)
75
- @logger.should_receive(:warn).once
74
+ expect(FileUtils).not_to receive(:mv)
75
+ expect(@logger).to receive(:warn).once
76
76
 
77
77
  another_file = "#@src_file.1"
78
78
  @maid.move([@src_file, another_file], @dst_dir)
@@ -93,17 +93,17 @@ module Maid
93
93
  end
94
94
 
95
95
  it 'creates needed directories' do
96
- File.directory?(@expanded_dst_dir).should be_false
96
+ expect(File.directory?(@expanded_dst_dir)).to be(false)
97
97
  @maid.rename(@src_file, @dst_name)
98
- File.directory?(@expanded_dst_dir).should be_true
98
+ expect(File.directory?(@expanded_dst_dir)).to be(true)
99
99
  end
100
100
 
101
101
  it 'moves the file from the source to the destination' do
102
- File.exists?(@expanded_src_name).should be_true
103
- File.exists?(@expanded_dst_name).should be_false
102
+ expect(File.exists?(@expanded_src_name)).to be(true)
103
+ expect(File.exists?(@expanded_dst_name)).to be(false)
104
104
  @maid.rename(@src_file, @dst_name)
105
- File.exists?(@expanded_src_name).should be_false
106
- File.exists?(@expanded_dst_name).should be_true
105
+ expect(File.exists?(@expanded_src_name)).to be(false)
106
+ expect(File.exists?(@expanded_dst_name)).to be(true)
107
107
  end
108
108
 
109
109
  context 'given the target already exists' do
@@ -113,7 +113,7 @@ module Maid
113
113
  end
114
114
 
115
115
  it 'does not move' do
116
- @logger.should_receive(:warn)
116
+ expect(@logger).to receive(:warn)
117
117
 
118
118
  @maid.rename(@src_file, @dst_name)
119
119
  end
@@ -130,43 +130,43 @@ module Maid
130
130
  @trash_file = File.join(@trash_path, @file_name)
131
131
  end
132
132
 
133
- it 'should move the path to the trash' do
133
+ it 'moves the path to the trash' do
134
134
  @maid.trash(@src_file)
135
- File.exist?(@trash_file).should be_true
135
+ expect(File.exist?(@trash_file)).to be(true)
136
136
  end
137
137
 
138
- it 'should use a safe path if the target exists' do
138
+ it 'uses a safe path if the target exists' do
139
139
  # Without an offset, ISO8601 parses to local time, which is what we want here.
140
140
  Timecop.freeze(Time.parse('2011-05-22T16:53:52')) do
141
141
  FileUtils.touch(@trash_file)
142
142
  @maid.trash(@src_file)
143
143
  new_trash_file = File.join(@trash_path, @file_name + ' 2011-05-22-16-53-52')
144
- File.exist?(new_trash_file).should be_true
144
+ expect(File.exist?(new_trash_file)).to be(true)
145
145
  end
146
146
  end
147
147
 
148
- it 'should handle multiple paths' do
148
+ it 'handles multiple paths' do
149
149
  second_src_file = @src_dir + (second_file_name = 'bar.zip')
150
150
  FileUtils.touch(second_src_file)
151
151
  @src_files = [@src_file, second_src_file]
152
152
  @maid.trash(@src_files)
153
153
 
154
154
  second_trash_file = File.join(@trash_path, second_file_name)
155
- File.exist?(@trash_file).should be_true
156
- File.exist?(second_trash_file).should be_true
155
+ expect(File.exist?(@trash_file)).to be(true)
156
+ expect(File.exist?(second_trash_file)).to be(true)
157
157
  end
158
158
 
159
- it 'should remove files greater then the remove option size' do
159
+ it 'removes files greater then the remove option size' do
160
160
  @maid.stub(:disk_usage) { 1025 }
161
161
  @maid.trash(@src_file, :remove_over => 1.mb)
162
- File.exist?(@src_file).should_not be_true
163
- File.exist?(@trash_file).should_not be_true
162
+ expect(File.exist?(@src_file)).not_to be(true)
163
+ expect(File.exist?(@trash_file)).not_to be(true)
164
164
  end
165
165
 
166
- it 'should trash files less then the remove option size' do
166
+ it 'trashes files less then the remove option size' do
167
167
  @maid.stub(:disk_usage) { 1023 }
168
168
  @maid.trash(@src_file, :remove_over => 1.mb)
169
- File.exist?(@trash_file).should be_true
169
+ expect(File.exist?(@trash_file)).to be(true)
170
170
  end
171
171
  end
172
172
 
@@ -179,36 +179,36 @@ module Maid
179
179
  @options = @maid.file_options
180
180
  end
181
181
 
182
- it 'should remove expanded paths, passing options' do
182
+ it 'removes expanded paths, passing options' do
183
183
  @maid.remove(@src_file)
184
- File.exist?(@src_file).should be_false
184
+ expect(File.exist?(@src_file)).to be(false)
185
185
  end
186
186
 
187
- it 'should log the remove' do
188
- @logger.should_receive(:info)
187
+ it 'logs the remove' do
188
+ expect(@logger).to receive(:info)
189
189
  @maid.remove(@src_file)
190
190
  end
191
191
 
192
- it 'should set the secure option' do
192
+ it 'sets the secure option' do
193
193
  @options = @options.merge(:secure => true)
194
- FileUtils.should_receive(:rm_r).with(@src_file_expand_path, @options)
194
+ expect(FileUtils).to receive(:rm_r).with(@src_file_expand_path, @options)
195
195
  @maid.remove(@src_file, :secure => true)
196
196
  end
197
197
 
198
- it 'should set the force option' do
198
+ it 'sets the force option' do
199
199
  @options = @options.merge(:force => true)
200
- FileUtils.should_receive(:rm_r).with(@src_file_expand_path, @options)
200
+ expect(FileUtils).to receive(:rm_r).with(@src_file_expand_path, @options)
201
201
  @maid.remove(@src_file, :force => true)
202
202
  end
203
203
 
204
- it 'should handle multiple paths' do
204
+ it 'handles multiple paths' do
205
205
  second_src_file = "#@src_dir/bar.zip"
206
206
  FileUtils.touch(second_src_file)
207
207
  @src_files = [@src_file, second_src_file]
208
208
 
209
209
  @maid.remove(@src_files)
210
- File.exist?(@src_file).should be_false
211
- File.exist?(second_src_file).should be_false
210
+ expect(File.exist?(@src_file)).to be(false)
211
+ expect(File.exist?(second_src_file)).to be(false)
212
212
  end
213
213
  end
214
214
 
@@ -220,14 +220,14 @@ module Maid
220
220
 
221
221
  it 'lists files in a directory' do
222
222
  FileUtils.touch(@file)
223
- @maid.dir('~/Downloads/*.zip').should == [@file]
223
+ expect(@maid.dir('~/Downloads/*.zip')).to eq([@file])
224
224
  end
225
225
 
226
226
  it 'lists multiple files in alphabetical order' do
227
227
  # It doesn't occur with `FakeFS` as far as I can tell, but Ubuntu (and possibly OS X) can give the results out
228
228
  # of lexical order. That makes using the `dry-run` output difficult to use.
229
229
  Dir.stub(:glob) { %w(/home/foo/b.zip /home/foo/a.zip /home/foo/c.zip) }
230
- @maid.dir('~/Downloads/*.zip').should == %w(/home/foo/a.zip /home/foo/b.zip /home/foo/c.zip)
230
+ expect(@maid.dir('~/Downloads/*.zip')).to eq(%w(/home/foo/a.zip /home/foo/b.zip /home/foo/c.zip))
231
231
  end
232
232
 
233
233
  context 'with multiple files' do
@@ -238,11 +238,11 @@ module Maid
238
238
  end
239
239
 
240
240
  it 'list files in all provided globs' do
241
- @maid.dir(%w(~/Downloads/*.tgz ~/Downloads/*.zip)).should == [@file, @other_file]
241
+ expect(@maid.dir(%w(~/Downloads/*.tgz ~/Downloads/*.zip))).to eq([@file, @other_file])
242
242
  end
243
243
 
244
244
  it 'lists files when using regexp-like glob patterns' do
245
- @maid.dir('~/Downloads/*.{tgz,zip}').should == [@file, @other_file]
245
+ expect(@maid.dir('~/Downloads/*.{tgz,zip}')).to eq([@file, @other_file])
246
246
  end
247
247
  end
248
248
 
@@ -255,11 +255,11 @@ module Maid
255
255
  end
256
256
 
257
257
  it 'lists files in directories when using regexp-like glob patterns' do
258
- @maid.dir('~/{Desktop,Downloads}/*.zip').should == [@other_file, @file]
258
+ expect(@maid.dir('~/{Desktop,Downloads}/*.zip')).to eq([@other_file, @file])
259
259
  end
260
260
 
261
261
  it 'lists files in directories when using recursive glob patterns' do
262
- @maid.dir('~/**/*.zip').should == [@other_file, @file]
262
+ expect(@maid.dir('~/**/*.zip')).to eq([@other_file, @file])
263
263
  end
264
264
  end
265
265
  end
@@ -273,14 +273,14 @@ module Maid
273
273
 
274
274
  it 'lists only files in a directory' do
275
275
  FileUtils.touch(@file)
276
- @maid.files('~/Downloads/*.zip').should == [@file]
276
+ expect(@maid.files('~/Downloads/*.zip')).to eq([@file])
277
277
  end
278
278
 
279
279
  it 'lists multiple files in alphabetical order' do
280
280
  # It doesn't occur with `FakeFS` as far as I can tell, but Ubuntu (and possibly OS X) can give the results out
281
281
  # of lexical order. That makes using the `dry-run` output difficult to use.
282
282
  Dir.stub(:glob) { %w(/home/foo/b.zip /home/foo/a.zip /home/foo/c.zip) }
283
- @maid.dir('~/Downloads/*.zip').should == %w(/home/foo/a.zip /home/foo/b.zip /home/foo/c.zip)
283
+ expect(@maid.dir('~/Downloads/*.zip')).to eq(%w(/home/foo/a.zip /home/foo/b.zip /home/foo/c.zip))
284
284
  end
285
285
 
286
286
  context 'with multiple files' do
@@ -291,11 +291,11 @@ module Maid
291
291
  end
292
292
 
293
293
  it 'list files in all provided globs' do
294
- @maid.dir(%w(~/Downloads/*.tgz ~/Downloads/*.zip)).should == [@file, @other_file]
294
+ expect(@maid.dir(%w(~/Downloads/*.tgz ~/Downloads/*.zip))).to eq([@file, @other_file])
295
295
  end
296
296
 
297
297
  it 'lists files when using regexp-like glob patterns' do
298
- @maid.dir('~/Downloads/*.{tgz,zip}').should == [@file, @other_file]
298
+ expect(@maid.dir('~/Downloads/*.{tgz,zip}')).to eq([@file, @other_file])
299
299
  end
300
300
  end
301
301
 
@@ -309,37 +309,37 @@ module Maid
309
309
  end
310
310
 
311
311
  it 'lists files in directories when using regexp-like glob patterns' do
312
- @maid.dir('~/{Desktop,Downloads}/*.zip').should == [@other_file, @file]
312
+ expect(@maid.dir('~/{Desktop,Downloads}/*.zip')).to eq([@other_file, @file])
313
313
  end
314
314
  end
315
315
  end
316
316
 
317
317
  describe '#escape_glob' do
318
318
  it 'escapes characters that have special meanings in globs' do
319
- @maid.escape_glob('test [tmp]').should == 'test \\[tmp\\]'
319
+ expect(@maid.escape_glob('test [tmp]')).to eq('test \\[tmp\\]')
320
320
  end
321
321
  end
322
322
 
323
323
  describe '#mkdir' do
324
- it 'should create a directory successfully' do
324
+ it 'creates a directory successfully' do
325
325
  @maid.mkdir('~/Downloads/Music/Pink.Floyd')
326
- File.exist?("#@home/Downloads/Music/Pink.Floyd").should be_true
326
+ expect(File.exist?("#@home/Downloads/Music/Pink.Floyd")).to be(true)
327
327
  end
328
328
 
329
- it 'should log the creation of the directory' do
330
- @logger.should_receive(:info)
329
+ it 'logs the creation of the directory' do
330
+ expect(@logger).to receive(:info)
331
331
  @maid.mkdir('~/Downloads/Music/Pink.Floyd')
332
332
  end
333
333
 
334
334
  it 'returns the path of the created directory' do
335
- @maid.mkdir('~/Reference/Foo').should == "#@home/Reference/Foo"
335
+ expect(@maid.mkdir('~/Reference/Foo')).to eq("#@home/Reference/Foo")
336
336
  end
337
337
 
338
338
  # FIXME: FakeFS doesn't seem to report `File.exist?` properly. However, this has been tested manually.
339
339
  #
340
- # it 'should respect the noop option' do
340
+ # it 'respects the noop option' do
341
341
  # @maid.mkdir('~/Downloads/Music/Pink.Floyd')
342
- # File.exist?("#@home/Downloads/Music/Pink.Floyd").should be_false
342
+ # expect(File.exist?("#@home/Downloads/Music/Pink.Floyd")).to be(false)
343
343
  # end
344
344
  end
345
345
 
@@ -352,21 +352,21 @@ module Maid
352
352
  @file_expand_path = File.expand_path(@file)
353
353
  end
354
354
 
355
- it 'should delegate to Find.find with an expanded path' do
356
- f = lambda { }
357
- Find.should_receive(:find).with(@file_expand_path, &f)
355
+ it 'delegates to Find.find with an expanded path' do
356
+ f = lambda { |arg| }
357
+ expect(Find).to receive(:find).with(@file_expand_path, &f)
358
358
  @maid.find(@file, &f)
359
359
  end
360
360
 
361
- it "should return an array of all the files' names when no block is given" do
362
- @maid.find(@dir).should == [@dir_expand_path, @file_expand_path]
361
+ it "returns an array of all the files' names when no block is given" do
362
+ expect(@maid.find(@dir)).to eq([@dir_expand_path, @file_expand_path])
363
363
  end
364
364
  end
365
365
 
366
366
  describe '#locate' do
367
- it 'should locate a file by name' do
368
- @maid.should_receive(:cmd).and_return("/a/foo.zip\n/b/foo.zip\n")
369
- @maid.locate('foo.zip').should == ['/a/foo.zip', '/b/foo.zip']
367
+ it 'locates a file by name' do
368
+ expect(@maid).to receive(:cmd).and_return("/a/foo.zip\n/b/foo.zip\n")
369
+ expect(@maid.locate('foo.zip')).to eq(['/a/foo.zip', '/b/foo.zip'])
370
370
  end
371
371
  end
372
372
 
@@ -375,52 +375,56 @@ module Maid
375
375
  Platform.stub(:osx?) { true }
376
376
  end
377
377
 
378
- it 'should determine the download site' do
379
- @maid.should_receive(:cmd).and_return(%((\n "http://www.site.com/foo.zip",\n"http://www.site.com/"\n)))
380
- @maid.downloaded_from('foo.zip').should == ['http://www.site.com/foo.zip', 'http://www.site.com/']
378
+ it 'determines the download site' do
379
+ expect(@maid).to receive(:cmd).and_return(%((\n "http://www.site.com/foo.zip",\n"http://www.site.com/"\n)))
380
+ expect(@maid.downloaded_from('foo.zip')).to eq(['http://www.site.com/foo.zip', 'http://www.site.com/'])
381
381
  end
382
382
  end
383
383
 
384
384
  describe '#downloading?' do
385
385
  it 'detects a normal file as not being downloaded' do
386
- @maid.downloading?('foo.zip').should be_false
386
+ expect(@maid.downloading?('foo.zip')).to be(false)
387
387
  end
388
388
 
389
389
  it 'detects when downloading in Firefox' do
390
- @maid.downloading?('foo.zip.part').should be_true
390
+ expect(@maid.downloading?('foo.zip.part')).to be(true)
391
391
  end
392
392
 
393
393
  it 'detects when downloading in Chrome' do
394
- @maid.downloading?('foo.zip.crdownload').should be_true
394
+ expect(@maid.downloading?('foo.zip.crdownload')).to be(true)
395
+ end
396
+
397
+ it 'detects when downloading in Safari' do
398
+ expect(@maid.downloading?('foo.zip.download')).to be (true)
395
399
  end
396
400
  end
397
401
 
398
402
  describe '#duration_s' do
399
- it 'should determine audio length' do
400
- @maid.should_receive(:cmd).and_return('235.705')
401
- @maid.duration_s('foo.mp3').should == 235.705
403
+ it 'determines audio length' do
404
+ expect(@maid).to receive(:cmd).and_return('235.705')
405
+ expect(@maid.duration_s('foo.mp3')).to eq(235.705)
402
406
  end
403
407
  end
404
408
 
405
409
  describe '#zipfile_contents' do
406
- it 'should inspect the contents of a .zip file' do
410
+ it 'inspects the contents of a .zip file' do
407
411
  entries = [double(:name => 'foo.exe'), double(:name => 'README.txt'), double(:name => 'subdir/anything.txt')]
408
412
  Zip::File.stub(:open).and_yield(entries)
409
413
 
410
- @maid.zipfile_contents('foo.zip').should == ['README.txt', 'foo.exe', 'subdir/anything.txt']
414
+ expect(@maid.zipfile_contents('foo.zip')).to eq(['README.txt', 'foo.exe', 'subdir/anything.txt'])
411
415
  end
412
416
  end
413
417
 
414
418
  describe '#disk_usage' do
415
- it 'should give the disk usage of a file' do
416
- @maid.should_receive(:cmd).and_return('136 foo.zip')
417
- @maid.disk_usage('foo.zip').should == 136
419
+ it 'gives the disk usage of a file' do
420
+ expect(@maid).to receive(:cmd).and_return('136 foo.zip')
421
+ expect(@maid.disk_usage('foo.zip')).to eq(136)
418
422
  end
419
423
 
420
424
  context 'when the file does not exist' do
421
425
  it 'raises an error' do
422
- @maid.should_receive(:cmd).and_return('du: cannot access `foo.zip\': No such file or directory')
423
- lambda { @maid.disk_usage('foo.zip') }.should raise_error(RuntimeError)
426
+ expect(@maid).to receive(:cmd).and_return('du: cannot access `foo.zip\': No such file or directory')
427
+ expect(lambda { @maid.disk_usage('foo.zip') }).to raise_error(RuntimeError)
424
428
  end
425
429
  end
426
430
  end
@@ -430,25 +434,25 @@ module Maid
430
434
  @path = "~/test.txt"
431
435
  end
432
436
 
433
- it 'should give the created time of the file' do
437
+ it 'gives the created time of the file' do
434
438
  Timecop.freeze(@now) do
435
439
  FileUtils.touch(File.expand_path(@path))
436
- @maid.created_at(@path).should == Time.now
440
+ expect(@maid.created_at(@path)).to eq(Time.now)
437
441
  end
438
442
  end
439
443
  end
440
444
 
441
445
  describe '#accessed_at' do
442
446
  # FakeFS does not implement atime.
443
- it 'should give the last accessed time of the file' do
444
- File.should_receive(:atime).with("#@home/foo.zip").and_return(@now)
445
- @maid.accessed_at('~/foo.zip').should == @now
447
+ it 'gives the last accessed time of the file' do
448
+ expect(File).to receive(:atime).with("#@home/foo.zip").and_return(@now)
449
+ expect(@maid.accessed_at('~/foo.zip')).to eq(@now)
446
450
  end
447
451
 
448
- it 'should trigger deprecation warning when last_accessed is used, but still run' do
449
- File.should_receive(:atime).with("#@home/foo.zip").and_return(@now)
450
- @maid.should have_deprecated_method(:last_accessed)
451
- @maid.last_accessed('~/foo.zip').should == @now
452
+ it 'triggers deprecation warning when last_accessed is used, but still run' do
453
+ expect(File).to receive(:atime).with("#@home/foo.zip").and_return(@now)
454
+ expect(@maid).to have_deprecated_method(:last_accessed)
455
+ expect(@maid.last_accessed('~/foo.zip')).to eq(@now)
452
456
  end
453
457
  end
454
458
 
@@ -458,13 +462,13 @@ module Maid
458
462
  FileUtils.touch(File.expand_path(@path))
459
463
  end
460
464
 
461
- it 'should give the modified time of the file' do
465
+ it 'gives the modified time of the file' do
462
466
  Timecop.freeze(@now) do
463
467
  File.open(@path, 'w') { |f| f.write('Test') }
464
468
  end
465
469
 
466
470
  # use to_i to ignore milliseconds during test
467
- @maid.modified_at(@path).to_i.should == @now.to_i
471
+ expect(@maid.modified_at(@path).to_i).to eq(@now.to_i)
468
472
  end
469
473
  end
470
474
 
@@ -473,9 +477,9 @@ module Maid
473
477
  @file = '~/foo.zip'
474
478
  end
475
479
 
476
- it 'should give the size of the file' do
477
- File.should_receive(:size).with(@file).and_return(42)
478
- @maid.size_of(@file).should == 42
480
+ it 'gives the size of the file' do
481
+ expect(File).to receive(:size).with(@file).and_return(42)
482
+ expect(@maid.size_of(@file)).to eq(42)
479
483
  end
480
484
  end
481
485
 
@@ -484,21 +488,21 @@ module Maid
484
488
  @file = '~/test.txt'
485
489
  end
486
490
 
487
- it 'should return the checksum of the file' do
488
- File.should_receive(:read).with(@file).and_return('contents')
489
- @maid.checksum_of(@file).should == Digest::MD5.hexdigest('contents')
491
+ it 'returns the checksum of the file' do
492
+ expect(File).to receive(:read).with(@file).and_return('contents')
493
+ expect(@maid.checksum_of(@file)).to eq(Digest::SHA1.hexdigest('contents'))
490
494
  end
491
495
  end
492
496
 
493
497
  describe '#git_piston' do
494
498
  it 'is deprecated' do
495
- @maid.should have_deprecated_method(:git_piston)
499
+ expect(@maid).to have_deprecated_method(:git_piston)
496
500
  @maid.git_piston('~/code/projectname')
497
501
  end
498
502
 
499
- it 'should pull and push the given git repository, logging the action' do
500
- @maid.should_receive(:cmd).with(%(cd #@home/code/projectname && git pull && git push 2>&1))
501
- @logger.should_receive(:info)
503
+ it 'ands pushes the given git repository, logging the action' do
504
+ expect(@maid).to receive(:cmd).with(%(cd #@home/code/projectname && git pull && git push 2>&1))
505
+ expect(@logger).to receive(:info)
502
506
  @maid.git_piston('~/code/projectname')
503
507
  end
504
508
  end
@@ -509,36 +513,35 @@ module Maid
509
513
  @dst_dir = '~/Reference'
510
514
  end
511
515
 
512
- it 'should sync the expanded paths, retaining backslash' do
513
- @maid.should_receive(:cmd).with(%(rsync -a -u #@home/Downloads/ #@home/Reference 2>&1))
516
+ it 'syncs the expanded paths, retaining backslash' do
517
+ expect(@maid).to receive(:cmd).with(%(rsync -a -u #@home/Downloads/ #@home/Reference 2>&1))
514
518
  @maid.sync(@src_dir, @dst_dir)
515
519
  end
516
520
 
517
- it 'should log the action' do
518
- @logger.should_receive(:info)
521
+ it 'logs the action' do
522
+ expect(@logger).to receive(:info)
519
523
  @maid.sync(@src_dir, @dst_dir)
520
524
  end
521
525
 
522
- it 'should have no options' do
523
- @maid.should_receive(:cmd).with(%(rsync #@home/Downloads/ #@home/Reference 2>&1))
526
+ it 'has no options' do
527
+ expect(@maid).to receive(:cmd).with(%(rsync #@home/Downloads/ #@home/Reference 2>&1))
524
528
  @maid.sync(@src_dir, @dst_dir, :archive => false, :update => false)
525
529
  end
526
530
 
527
- it 'should add all options' do
528
- @maid.should_receive(:cmd).with(%(rsync -a -v -u -m --exclude=.git --delete #@home/Downloads/ #@home/Reference 2>&1))
531
+ it 'adds all options' do
532
+ expect(@maid).to receive(:cmd).with(%(rsync -a -v -u -m --exclude=.git --delete #@home/Downloads/ #@home/Reference 2>&1))
529
533
  @maid.sync(@src_dir, @dst_dir, :archive => true, :update => true, :delete => true, :verbose => true, :prune_empty => true, :exclude => '.git')
530
534
  end
531
535
 
532
- it 'should add multiple exlcude options' do
533
- @maid.
534
- should_receive(:cmd).
536
+ it 'adds multiple exlcude options' do
537
+ expect(@maid).to receive(:cmd).
535
538
  with(%(rsync -a -u --exclude=.git --exclude=.rvmrc #@home/Downloads/ #@home/Reference 2>&1))
536
539
  @maid.sync(@src_dir, @dst_dir, :exclude => ['.git', '.rvmrc'])
537
540
  end
538
541
 
539
- it 'should add noop option' do
542
+ it 'adds noop option' do
540
543
  @maid.file_options[:noop] = true
541
- @maid.should_receive(:cmd).with(%(rsync -a -u -n #@home/Downloads/ #@home/Reference 2>&1))
544
+ expect(@maid).to receive(:cmd).with(%(rsync -a -u -n #@home/Downloads/ #@home/Reference 2>&1))
542
545
  @maid.sync(@src_dir, @dst_dir)
543
546
  end
544
547
  end
@@ -556,26 +559,26 @@ module Maid
556
559
  end
557
560
 
558
561
  describe '#dupes_in' do
559
- it 'should list duplicate files in arrays' do
562
+ it 'lists duplicate files in arrays' do
560
563
  dupes = @maid.dupes_in(file_fixtures_glob)
561
- dupes.first.should be_kind_of(Array)
564
+ expect(dupes.first).to be_kind_of(Array)
562
565
 
563
566
  basenames = dupes.flatten.map { |p| File.basename(p) }
564
- basenames.should == %w(1.zip bar.zip foo.zip)
567
+ expect(basenames).to eq(%w(1.zip bar.zip foo.zip))
565
568
  end
566
569
  end
567
570
 
568
571
  describe '#verbose_dupes_in' do
569
- it 'should list all but the shortest-named dupe' do
572
+ it 'lists all but the shortest-named dupe' do
570
573
  dupes = @maid.verbose_dupes_in(file_fixtures_glob)
571
574
 
572
575
  basenames = dupes.flatten.map { |p| File.basename(p) }
573
- basenames.should == %w(bar.zip foo.zip)
576
+ expect(basenames).to eq(%w(bar.zip foo.zip))
574
577
  end
575
578
  end
576
579
 
577
580
  describe '#newest_dupes_in' do
578
- it 'should list all but the oldest dupe' do
581
+ it 'lists all but the oldest dupe' do
579
582
  # FIXME: Broken on Ruby 2.1.0-preview2, maybe because of FakeFS
580
583
  #
581
584
  # oldest_path = "#{file_fixtures_path}/foo.zip"
@@ -587,20 +590,20 @@ module Maid
587
590
  dupes = @maid.newest_dupes_in(file_fixtures_glob)
588
591
 
589
592
  basenames = dupes.flatten.map { |p| File.basename(p) }
590
- basenames.should == %w(bar.zip 1.zip)
593
+ expect(basenames).to eq(%w(bar.zip 1.zip))
591
594
  end
592
595
  end
593
596
 
594
597
  describe '#mime_type' do
595
598
  context 'given a JPEG image' do
596
599
  it 'reports "image/jpeg"' do
597
- @maid.mime_type(image_path).should == 'image/jpeg'
600
+ expect(@maid.mime_type(image_path)).to eq('image/jpeg')
598
601
  end
599
602
  end
600
603
 
601
604
  context 'given an unknown type' do
602
605
  it 'returns nil' do
603
- @maid.mime_type(unknown_path).should be_nil
606
+ expect(@maid.mime_type(unknown_path)).to be_nil
604
607
  end
605
608
  end
606
609
  end
@@ -608,13 +611,13 @@ module Maid
608
611
  describe '#media_type' do
609
612
  context 'given a JPEG image' do
610
613
  it 'reports "image"' do
611
- @maid.media_type(image_path).should == 'image'
614
+ expect(@maid.media_type(image_path)).to eq('image')
612
615
  end
613
616
  end
614
617
 
615
618
  context 'given an unknown type' do
616
619
  it 'returns nil' do
617
- @maid.media_type(unknown_path).should be_nil
620
+ expect(@maid.media_type(unknown_path)).to be_nil
618
621
  end
619
622
  end
620
623
  end
@@ -624,8 +627,8 @@ module Maid
624
627
  it 'only lists the fixture JPEG' do
625
628
  matches = @maid.where_content_type(@maid.dir(file_fixtures_glob), 'image')
626
629
 
627
- matches.length.should == 1
628
- matches.first.should end_with('spec/fixtures/files/ruby.jpg')
630
+ expect(matches.length).to eq(1)
631
+ expect(matches.first).to end_with('spec/fixtures/files/ruby.jpg')
629
632
  end
630
633
  end
631
634
  end