memfs 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +29 -0
- data/CHANGELOG.md +7 -0
- data/Guardfile +5 -6
- data/README.md +6 -6
- data/Rakefile +9 -1
- data/lib/memfs.rb +6 -4
- data/lib/memfs/dir.rb +17 -21
- data/lib/memfs/fake/entry.rb +2 -2
- data/lib/memfs/fake/file/content.rb +3 -2
- data/lib/memfs/file.rb +54 -116
- data/lib/memfs/file/stat.rb +2 -2
- data/lib/memfs/file_system.rb +11 -13
- data/lib/memfs/io.rb +201 -0
- data/lib/memfs/version.rb +1 -1
- data/memfs.gemspec +17 -17
- data/memfs.png +0 -0
- data/spec/fileutils_spec.rb +233 -228
- data/spec/memfs/dir_spec.rb +76 -76
- data/spec/memfs/fake/directory_spec.rb +20 -20
- data/spec/memfs/fake/entry_spec.rb +24 -24
- data/spec/memfs/fake/file/content_spec.rb +43 -45
- data/spec/memfs/fake/file_spec.rb +14 -14
- data/spec/memfs/fake/symlink_spec.rb +22 -22
- data/spec/memfs/file/stat_spec.rb +314 -314
- data/spec/memfs/file_spec.rb +1636 -970
- data/spec/memfs/file_system_spec.rb +83 -83
- data/spec/memfs_spec.rb +15 -15
- data/spec/spec_helper.rb +17 -1
- metadata +36 -57
data/spec/memfs_spec.rb
CHANGED
@@ -4,20 +4,20 @@ describe MemFs do
|
|
4
4
|
subject { MemFs }
|
5
5
|
|
6
6
|
describe '.activate' do
|
7
|
-
it
|
7
|
+
it 'calls the given block with MemFs activated' do
|
8
8
|
subject.activate do
|
9
9
|
expect(::Dir).to be(MemFs::Dir)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it 'resets the original classes once finished' do
|
14
14
|
subject.activate {}
|
15
15
|
expect(::Dir).to be(MemFs::OriginalDir)
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'deactivates MemFs even when an exception occurs' do
|
19
19
|
begin
|
20
|
-
subject.activate {
|
20
|
+
subject.activate { fail 'Some error' }
|
21
21
|
rescue
|
22
22
|
end
|
23
23
|
expect(::Dir).to be(MemFs::OriginalDir)
|
@@ -28,11 +28,11 @@ describe MemFs do
|
|
28
28
|
before(:each) { subject.activate! }
|
29
29
|
after(:each) { subject.deactivate! }
|
30
30
|
|
31
|
-
it
|
31
|
+
it 'replaces Ruby Dir class with a fake one' do
|
32
32
|
expect(::Dir).to be(MemFs::Dir)
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it 'replaces Ruby File class with a fake one' do
|
36
36
|
expect(::File).to be(MemFs::File)
|
37
37
|
end
|
38
38
|
end
|
@@ -43,11 +43,11 @@ describe MemFs do
|
|
43
43
|
subject.deactivate!
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it 'sets back the Ruby Dir class to the original one' do
|
47
47
|
expect(::Dir).to be(MemFs::OriginalDir)
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
50
|
+
it 'sets back the Ruby File class to the original one' do
|
51
51
|
expect(::File).to be(MemFs::OriginalFile)
|
52
52
|
end
|
53
53
|
end
|
@@ -56,25 +56,25 @@ describe MemFs do
|
|
56
56
|
around(:each) { |example| MemFs.activate { example.run } }
|
57
57
|
|
58
58
|
it 'creates the specified file' do
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
_fs.mkdir('/path')
|
60
|
+
_fs.mkdir('/path/to')
|
61
|
+
_fs.mkdir('/path/to/some')
|
62
62
|
subject.touch('/path/to/some/file.rb')
|
63
|
-
expect(File.exist?('/path/to/some/file.rb')).to
|
63
|
+
expect(File.exist?('/path/to/some/file.rb')).to be true
|
64
64
|
end
|
65
65
|
|
66
66
|
context 'when the parent folder do not exist' do
|
67
67
|
it 'creates them all' do
|
68
68
|
subject.touch('/path/to/some/file.rb')
|
69
|
-
expect(File.exist?('/path/to/some/file.rb')).to
|
69
|
+
expect(File.exist?('/path/to/some/file.rb')).to be true
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
context 'when several files are specified' do
|
74
74
|
it 'creates every file' do
|
75
75
|
subject.touch('/some/path', '/other/path')
|
76
|
-
expect(File.exist?('/some/path')).to
|
77
|
-
expect(File.exist?('/other/path')).to
|
76
|
+
expect(File.exist?('/some/path')).to be true
|
77
|
+
expect(File.exist?('/other/path')).to be true
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,6 +15,22 @@ RSpec.configure do |config|
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
RSpec::Matchers.define :raise_specific_error do |expected_exception_class|
|
19
|
+
match do |block|
|
20
|
+
begin
|
21
|
+
block.call
|
22
|
+
rescue expected_exception_class
|
23
|
+
true
|
24
|
+
else
|
25
|
+
false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def supports_block_expectations?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def _fs
|
19
35
|
MemFs::FileSystem.instance
|
20
36
|
end
|
metadata
CHANGED
@@ -1,142 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Simon COURTOIS
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-02-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: coveralls
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0.6'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.6'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '10.0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '10.0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '3.0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
54
|
+
version: '3.0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: guard
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
61
|
+
version: '2.6'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
68
|
+
version: '2.6'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: guard-rspec
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- - ~>
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
|
-
version: '
|
75
|
+
version: '4.3'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- - ~>
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
82
|
+
version: '4.3'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rb-inotify
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- - ~>
|
87
|
+
- - "~>"
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0.8'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- - ~>
|
94
|
+
- - "~>"
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0.8'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: rb-fsevent
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- - ~>
|
101
|
+
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0.9'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- - ~>
|
108
|
+
- - "~>"
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0.9'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: rb-fchange
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- - ~>
|
115
|
+
- - "~>"
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0.0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- - ~>
|
122
|
+
- - "~>"
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0.0'
|
142
125
|
description: MemFs provides a fake file system that can be used for tests. Strongly
|
@@ -147,9 +130,10 @@ executables: []
|
|
147
130
|
extensions: []
|
148
131
|
extra_rdoc_files: []
|
149
132
|
files:
|
150
|
-
- .gitignore
|
151
|
-
- .rspec
|
152
|
-
- .
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- ".travis.yml"
|
153
137
|
- CHANGELOG.md
|
154
138
|
- Gemfile
|
155
139
|
- Guardfile
|
@@ -167,8 +151,10 @@ files:
|
|
167
151
|
- lib/memfs/file/stat.rb
|
168
152
|
- lib/memfs/file_system.rb
|
169
153
|
- lib/memfs/filesystem_access.rb
|
154
|
+
- lib/memfs/io.rb
|
170
155
|
- lib/memfs/version.rb
|
171
156
|
- memfs.gemspec
|
157
|
+
- memfs.png
|
172
158
|
- spec/fileutils_spec.rb
|
173
159
|
- spec/memfs/dir_spec.rb
|
174
160
|
- spec/memfs/fake/directory_spec.rb
|
@@ -184,34 +170,27 @@ files:
|
|
184
170
|
homepage: http://github.com/simonc/memfs
|
185
171
|
licenses:
|
186
172
|
- MIT
|
173
|
+
metadata: {}
|
187
174
|
post_install_message:
|
188
175
|
rdoc_options: []
|
189
176
|
require_paths:
|
190
177
|
- lib
|
191
178
|
required_ruby_version: !ruby/object:Gem::Requirement
|
192
|
-
none: false
|
193
179
|
requirements:
|
194
|
-
- -
|
180
|
+
- - ">="
|
195
181
|
- !ruby/object:Gem::Version
|
196
182
|
version: '0'
|
197
|
-
segments:
|
198
|
-
- 0
|
199
|
-
hash: 1081085221049252726
|
200
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
184
|
requirements:
|
203
|
-
- -
|
185
|
+
- - ">="
|
204
186
|
- !ruby/object:Gem::Version
|
205
187
|
version: '0'
|
206
|
-
segments:
|
207
|
-
- 0
|
208
|
-
hash: 1081085221049252726
|
209
188
|
requirements: []
|
210
189
|
rubyforge_project:
|
211
|
-
rubygems_version:
|
190
|
+
rubygems_version: 2.4.5
|
212
191
|
signing_key:
|
213
|
-
specification_version:
|
214
|
-
summary: memfs-0.4.
|
192
|
+
specification_version: 4
|
193
|
+
summary: memfs-0.4.2
|
215
194
|
test_files:
|
216
195
|
- spec/fileutils_spec.rb
|
217
196
|
- spec/memfs/dir_spec.rb
|