memfs 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -289,6 +289,18 @@ module MemFs
289
289
  expect(subject.find!('/new-dir')).to be_a(Fake::Directory)
290
290
  end
291
291
 
292
+ it 'sets directory permissions to default 0777' do
293
+ subject.mkdir '/new-dir'
294
+ expect(subject.find!('/new-dir').mode).to eq(0100777)
295
+ end
296
+
297
+ context 'when permissions are specified' do
298
+ it 'sets directory permission to specified value' do
299
+ subject.mkdir '/new-dir', 0644
300
+ expect(subject.find!('/new-dir').mode).to eq(0100644)
301
+ end
302
+ end
303
+
292
304
  context 'when a relative path is given' do
293
305
  it 'creates a directory in current directory' do
294
306
  subject.chdir '/test-dir'
data/spec/memfs_spec.rb CHANGED
@@ -1,78 +1,76 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe MemFs do
4
- subject { MemFs }
5
-
6
4
  describe '.activate' do
7
5
  it 'calls the given block with MemFs activated' do
8
- subject.activate do
9
- expect(::Dir).to be(MemFs::Dir)
6
+ described_class.activate do
7
+ expect(::Dir).to be(described_class::Dir)
10
8
  end
11
9
  end
12
10
 
13
11
  it 'resets the original classes once finished' do
14
- subject.activate {}
15
- expect(::Dir).to be(MemFs::OriginalDir)
12
+ described_class.activate {}
13
+ expect(::Dir).to be(described_class::OriginalDir)
16
14
  end
17
15
 
18
16
  it 'deactivates MemFs even when an exception occurs' do
19
17
  begin
20
- subject.activate { fail 'Some error' }
18
+ described_class.activate { fail 'Some error' }
21
19
  rescue
22
20
  end
23
- expect(::Dir).to be(MemFs::OriginalDir)
21
+ expect(::Dir).to be(described_class::OriginalDir)
24
22
  end
25
23
  end
26
24
 
27
25
  describe '.activate!' do
28
- before(:each) { subject.activate! }
29
- after(:each) { subject.deactivate! }
26
+ before(:each) { described_class.activate! }
27
+ after(:each) { described_class.deactivate! }
30
28
 
31
29
  it 'replaces Ruby Dir class with a fake one' do
32
- expect(::Dir).to be(MemFs::Dir)
30
+ expect(::Dir).to be(described_class::Dir)
33
31
  end
34
32
 
35
33
  it 'replaces Ruby File class with a fake one' do
36
- expect(::File).to be(MemFs::File)
34
+ expect(::File).to be(described_class::File)
37
35
  end
38
36
  end
39
37
 
40
38
  describe '.deactivate!' do
41
39
  before :each do
42
- subject.activate!
43
- subject.deactivate!
40
+ described_class.activate!
41
+ described_class.deactivate!
44
42
  end
45
43
 
46
44
  it 'sets back the Ruby Dir class to the original one' do
47
- expect(::Dir).to be(MemFs::OriginalDir)
45
+ expect(::Dir).to be(described_class::OriginalDir)
48
46
  end
49
47
 
50
48
  it 'sets back the Ruby File class to the original one' do
51
- expect(::File).to be(MemFs::OriginalFile)
49
+ expect(::File).to be(described_class::OriginalFile)
52
50
  end
53
51
  end
54
52
 
55
53
  describe '.touch' do
56
- around(:each) { |example| MemFs.activate { example.run } }
54
+ around(:each) { |example| described_class.activate { example.run } }
57
55
 
58
56
  it 'creates the specified file' do
59
57
  _fs.mkdir('/path')
60
58
  _fs.mkdir('/path/to')
61
59
  _fs.mkdir('/path/to/some')
62
- subject.touch('/path/to/some/file.rb')
60
+ described_class.touch('/path/to/some/file.rb')
63
61
  expect(File.exist?('/path/to/some/file.rb')).to be true
64
62
  end
65
63
 
66
64
  context 'when the parent folder do not exist' do
67
65
  it 'creates them all' do
68
- subject.touch('/path/to/some/file.rb')
66
+ described_class.touch('/path/to/some/file.rb')
69
67
  expect(File.exist?('/path/to/some/file.rb')).to be true
70
68
  end
71
69
  end
72
70
 
73
71
  context 'when several files are specified' do
74
72
  it 'creates every file' do
75
- subject.touch('/some/path', '/other/path')
73
+ described_class.touch('/some/path', '/other/path')
76
74
  expect(File.exist?('/some/path')).to be true
77
75
  expect(File.exist?('/other/path')).to be true
78
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon COURTOIS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-14 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -190,7 +190,7 @@ rubyforge_project:
190
190
  rubygems_version: 2.4.5
191
191
  signing_key:
192
192
  specification_version: 4
193
- summary: memfs-0.4.3
193
+ summary: memfs-0.5.0
194
194
  test_files:
195
195
  - spec/fileutils_spec.rb
196
196
  - spec/memfs/dir_spec.rb