memfs 0.4.3 → 0.5.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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/README.md +3 -2
- data/lib/memfs/dir.rb +2 -2
- data/lib/memfs/file_system.rb +4 -2
- data/lib/memfs/version.rb +1 -1
- data/spec/fileutils_spec.rb +229 -191
- data/spec/memfs/dir_spec.rb +109 -95
- data/spec/memfs/fake/directory_spec.rb +8 -8
- data/spec/memfs/fake/entry_spec.rb +3 -3
- data/spec/memfs/fake/file/content_spec.rb +3 -5
- data/spec/memfs/fake/symlink_spec.rb +11 -11
- data/spec/memfs/file/stat_spec.rb +14 -14
- data/spec/memfs/file_spec.rb +269 -269
- data/spec/memfs/file_system_spec.rb +12 -0
- data/spec/memfs_spec.rb +18 -20
- metadata +3 -3
@@ -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
|
-
|
9
|
-
expect(::Dir).to be(
|
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
|
-
|
15
|
-
expect(::Dir).to be(
|
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
|
-
|
18
|
+
described_class.activate { fail 'Some error' }
|
21
19
|
rescue
|
22
20
|
end
|
23
|
-
expect(::Dir).to be(
|
21
|
+
expect(::Dir).to be(described_class::OriginalDir)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
25
|
describe '.activate!' do
|
28
|
-
before(:each) {
|
29
|
-
after(:each) {
|
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(
|
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(
|
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
|
-
|
43
|
-
|
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(
|
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(
|
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|
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
+
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-
|
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.
|
193
|
+
summary: memfs-0.5.0
|
194
194
|
test_files:
|
195
195
|
- spec/fileutils_spec.rb
|
196
196
|
- spec/memfs/dir_spec.rb
|