memfs 0.5.0 → 1.0.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/.gitignore +1 -0
- data/.hound.yml +2 -0
- data/.rspec +1 -1
- data/.rubocop.yml +1 -0
- data/.ruby-style.yml +335 -0
- data/.travis.yml +6 -3
- data/CHANGELOG.md +12 -1
- data/README.md +6 -5
- data/lib/memfs.rb +29 -2
- data/lib/memfs/dir.rb +6 -6
- data/lib/memfs/fake/directory.rb +5 -2
- data/lib/memfs/fake/file.rb +4 -5
- data/lib/memfs/fake/file/content.rb +0 -2
- data/lib/memfs/file.rb +27 -20
- data/lib/memfs/file/stat.rb +1 -1
- data/lib/memfs/file_system.rb +3 -3
- data/lib/memfs/io.rb +190 -154
- data/lib/memfs/version.rb +1 -1
- data/memfs.gemspec +4 -1
- data/spec/fileutils_spec.rb +23 -18
- data/spec/memfs/dir_spec.rb +20 -9
- data/spec/memfs/fake/directory_spec.rb +5 -1
- data/spec/memfs/fake/entry_spec.rb +5 -5
- data/spec/memfs/fake/file/content_spec.rb +1 -1
- data/spec/memfs/fake/file_spec.rb +1 -1
- data/spec/memfs/fake/symlink_spec.rb +2 -2
- data/spec/memfs/file/stat_spec.rb +6 -3
- data/spec/memfs/file_spec.rb +140 -57
- data/spec/memfs/file_system_spec.rb +5 -4
- data/spec/memfs_spec.rb +39 -2
- data/spec/spec_helper.rb +23 -21
- metadata +22 -6
- data/.rubocop.yml +0 -29
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module MemFs
|
4
|
-
describe FileSystem do
|
4
|
+
::RSpec.describe FileSystem do
|
5
5
|
subject { _fs }
|
6
6
|
|
7
7
|
before :each do
|
@@ -200,7 +200,7 @@ module MemFs
|
|
200
200
|
|
201
201
|
context 'when there is no entry for the given path' do
|
202
202
|
it 'raises an exception' do
|
203
|
-
expect { subject.find!('/no-file') }.to
|
203
|
+
expect { subject.find!('/no-file') }.to raise_error Errno::ENOENT
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
@@ -221,7 +221,7 @@ module MemFs
|
|
221
221
|
it 'raises an exception' do
|
222
222
|
expect {
|
223
223
|
subject.find!('/test-no-link/test-file')
|
224
|
-
}.to raise_error
|
224
|
+
}.to raise_error Errno::ENOENT
|
225
225
|
end
|
226
226
|
end
|
227
227
|
end
|
@@ -374,6 +374,7 @@ module MemFs
|
|
374
374
|
|
375
375
|
describe '#symlink' do
|
376
376
|
it 'creates a symbolic link' do
|
377
|
+
subject.touch('/some-file')
|
377
378
|
subject.symlink('/some-file', '/some-link')
|
378
379
|
expect(subject.find!('/some-link')).to be_a(Fake::Symlink)
|
379
380
|
end
|
@@ -433,7 +434,7 @@ module MemFs
|
|
433
434
|
|
434
435
|
context 'when the entry is a directory' do
|
435
436
|
it 'raises an exception' do
|
436
|
-
expect { subject.unlink('/test-dir') }.to raise_error
|
437
|
+
expect { subject.unlink('/test-dir') }.to raise_error Errno::EPERM
|
437
438
|
end
|
438
439
|
end
|
439
440
|
end
|
data/spec/memfs_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe MemFs do
|
3
|
+
RSpec.describe MemFs do
|
4
4
|
describe '.activate' do
|
5
5
|
it 'calls the given block with MemFs activated' do
|
6
6
|
described_class.activate do
|
@@ -16,7 +16,7 @@ describe MemFs do
|
|
16
16
|
it 'deactivates MemFs even when an exception occurs' do
|
17
17
|
begin
|
18
18
|
described_class.activate { fail 'Some error' }
|
19
|
-
rescue
|
19
|
+
rescue RuntimeError
|
20
20
|
end
|
21
21
|
expect(::Dir).to be(described_class::OriginalDir)
|
22
22
|
end
|
@@ -50,6 +50,43 @@ describe MemFs do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
describe '.halt' do
|
54
|
+
before(:each) { described_class.activate! }
|
55
|
+
after(:each) { described_class.deactivate! }
|
56
|
+
|
57
|
+
it 'switches back to the original Ruby Dir & File classes' do
|
58
|
+
described_class.halt do
|
59
|
+
expect(::Dir).to be(described_class::OriginalDir)
|
60
|
+
expect(::File).to be(described_class::OriginalFile)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'switches back to the faked Dir & File classes' do
|
65
|
+
described_class.halt
|
66
|
+
expect(::Dir).to be(described_class::Dir)
|
67
|
+
expect(::File).to be(described_class::File)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'switches back to the faked Dir & File classes no matter what' do
|
71
|
+
begin
|
72
|
+
described_class.halt { raise StandardError.new }
|
73
|
+
rescue
|
74
|
+
expect(::Dir).to be(described_class::Dir)
|
75
|
+
expect(::File).to be(described_class::File)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'maintains the state of the faked fs' do
|
80
|
+
_fs.touch('file.rb')
|
81
|
+
|
82
|
+
described_class.halt do
|
83
|
+
expect(File.exist?('file.rb')).to be false
|
84
|
+
end
|
85
|
+
|
86
|
+
expect(File.exist?('file.rb')).to be true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
53
90
|
describe '.touch' do
|
54
91
|
around(:each) { |example| described_class.activate { example.run } }
|
55
92
|
|
data/spec/spec_helper.rb
CHANGED
@@ -3,34 +3,36 @@ require 'memfs'
|
|
3
3
|
|
4
4
|
Coveralls.wear!
|
5
5
|
|
6
|
+
def _fs
|
7
|
+
MemFs::FileSystem.instance
|
8
|
+
end
|
9
|
+
|
6
10
|
RSpec.configure do |config|
|
7
|
-
config.
|
8
|
-
|
11
|
+
config.expect_with :rspec do |expectations|
|
12
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
9
13
|
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
expect(subject.method(method)).to eq(subject.method(original_method))
|
14
|
-
end
|
15
|
+
config.mock_with :rspec do |mocks|
|
16
|
+
mocks.verify_partial_doubles = true
|
15
17
|
end
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
false
|
26
|
-
end
|
19
|
+
config.filter_run :focus
|
20
|
+
config.run_all_when_everything_filtered = true
|
21
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
22
|
+
config.disable_monkey_patching!
|
23
|
+
config.warnings = true
|
24
|
+
if config.files_to_run.one?
|
25
|
+
config.default_formatter = 'doc'
|
27
26
|
end
|
27
|
+
# config.profile_examples = 10
|
28
|
+
config.order = :random
|
29
|
+
Kernel.srand config.seed
|
28
30
|
|
29
|
-
|
30
|
-
true
|
31
|
-
end
|
31
|
+
config.before { MemFs::FileSystem.instance.clear! }
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
RSpec.shared_examples 'aliased method' do |method, original_method|
|
35
|
+
it "##{original_method}" do
|
36
|
+
expect(subject.method(method)).to eq(subject.method(original_method))
|
37
|
+
end
|
36
38
|
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: 1.0.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:
|
11
|
+
date: 2017-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: listen
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.1'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.1'
|
125
139
|
description: MemFs provides a fake file system that can be used for tests. Strongly
|
126
140
|
inspired by FakeFS.
|
127
141
|
email:
|
@@ -131,8 +145,10 @@ extensions: []
|
|
131
145
|
extra_rdoc_files: []
|
132
146
|
files:
|
133
147
|
- ".gitignore"
|
148
|
+
- ".hound.yml"
|
134
149
|
- ".rspec"
|
135
150
|
- ".rubocop.yml"
|
151
|
+
- ".ruby-style.yml"
|
136
152
|
- ".travis.yml"
|
137
153
|
- CHANGELOG.md
|
138
154
|
- Gemfile
|
@@ -187,10 +203,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
203
|
version: '0'
|
188
204
|
requirements: []
|
189
205
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
206
|
+
rubygems_version: 2.6.8
|
191
207
|
signing_key:
|
192
208
|
specification_version: 4
|
193
|
-
summary: memfs-0.
|
209
|
+
summary: memfs-1.0.0
|
194
210
|
test_files:
|
195
211
|
- spec/fileutils_spec.rb
|
196
212
|
- spec/memfs/dir_spec.rb
|
data/.rubocop.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
AlignParameters:
|
2
|
-
Enabled: false
|
3
|
-
|
4
|
-
Blocks:
|
5
|
-
Enabled: false
|
6
|
-
|
7
|
-
ClassLength:
|
8
|
-
Enabled: false
|
9
|
-
|
10
|
-
Documentation:
|
11
|
-
Enabled: false
|
12
|
-
|
13
|
-
DoubleNegation:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
EmptyLinesAroundBody:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
LineLength:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
PercentLiteralDelimiters:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
SpecialGlobalVars:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
TrivialAccessors:
|
29
|
-
Enabled: false
|