fakefs 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -10
- data/lib/fakefs/base.rb +1 -1
- data/lib/fakefs/dir.rb +7 -5
- data/lib/fakefs/file.rb +16 -9
- data/lib/fakefs/fileutils.rb +3 -3
- data/lib/fakefs/pathname.rb +4 -4
- data/lib/fakefs/version.rb +1 -1
- metadata +11 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8bd326fd88f546556eaca2194662454a12234d2da597e8002a663e5dba757cb
|
4
|
+
data.tar.gz: c70378d690483115a4419f80d11a5775b0848c7fd2a2ceaec098f07b4196d6c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf22c7d97a54dbc02f382ba3ee7feb75673e792340336446816411bbae4b04886d9b1b7587a4230aee0c0f12ff64ad42102d4e3369dad223c3d27444b63f34b6
|
7
|
+
data.tar.gz: 96077a4735d8a880bb8073e5abc2c8869a99b688b18082253f0eb026800c11df7dcdb139a0e22be2e6993b1caadf86b12adb76eadd2dfd20c4ea2877b1cc39db
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
FakeFS [![build status](https://
|
1
|
+
FakeFS [![build status](https://github.com/fakefs/fakefs/workflows/CI/badge.svg)](https://github.com/fakefs/fakefs/actions?query=branch%3Amaster)
|
2
2
|
======
|
3
3
|
|
4
4
|
Mocking calls to FileUtils or File means tightly coupling tests with the implementation.
|
@@ -159,14 +159,6 @@ FakeFS::File.class_eval do
|
|
159
159
|
end
|
160
160
|
```
|
161
161
|
|
162
|
-
[MockFS](http://mockfs.rubyforge.org/) comparison
|
163
|
-
----------------------------------
|
164
|
-
|
165
|
-
FakeFS provides a test suite and works with symlinks. It's also strictly a
|
166
|
-
test-time dependency: your actual library does not need to use or know about
|
167
|
-
FakeFS.
|
168
|
-
|
169
|
-
|
170
162
|
Caveats
|
171
163
|
-------
|
172
164
|
|
@@ -210,7 +202,7 @@ Meta
|
|
210
202
|
* Code: `git clone git://github.com/fakefs/fakefs.git`
|
211
203
|
* Home: <https://github.com/fakefs/fakefs>
|
212
204
|
* Bugs: <https://github.com/fakefs/fakefs/issues>
|
213
|
-
* Test: <https://
|
205
|
+
* Test: <https://github.com/fakefs/fakefs/actions?query=branch%3Amaster>
|
214
206
|
* Gems: <https://rubygems.org/gems/fakefs>
|
215
207
|
|
216
208
|
[0]: https://help.github.com/forking/
|
data/lib/fakefs/base.rb
CHANGED
data/lib/fakefs/dir.rb
CHANGED
@@ -85,14 +85,14 @@ module FakeFS
|
|
85
85
|
FileSystem.delete(string)
|
86
86
|
end
|
87
87
|
|
88
|
-
def self.entries(dirname,
|
88
|
+
def self.entries(dirname, _options = nil)
|
89
89
|
_check_for_valid_file(dirname)
|
90
90
|
|
91
91
|
Dir.new(dirname).map { |file| File.basename(file) }
|
92
92
|
end
|
93
93
|
|
94
|
-
def self.children(dirname,
|
95
|
-
entries(dirname
|
94
|
+
def self.children(dirname, _options = nil)
|
95
|
+
entries(dirname) - ['.', '..']
|
96
96
|
end
|
97
97
|
|
98
98
|
def self.each_child(dirname, &_block)
|
@@ -198,11 +198,13 @@ module FakeFS
|
|
198
198
|
opts = {}
|
199
199
|
end
|
200
200
|
tmpdir, = *rest
|
201
|
-
tmpdir ||= self.tmpdir
|
201
|
+
tmpdir ||= self.tmpdir
|
202
|
+
Dir.mkdir(tmpdir) unless Dir.exist?(tmpdir)
|
203
|
+
|
202
204
|
n = nil
|
203
205
|
begin
|
204
206
|
path = File.join(tmpdir, make_tmpname(basename, n))
|
205
|
-
yield(path, n,
|
207
|
+
yield(path, n, opts)
|
206
208
|
rescue Errno::EEXIST
|
207
209
|
n ||= 0
|
208
210
|
n += 1
|
data/lib/fakefs/file.rb
CHANGED
@@ -53,6 +53,10 @@ module FakeFS
|
|
53
53
|
class << self
|
54
54
|
alias exists? exist?
|
55
55
|
|
56
|
+
def identical?(one_path, another_path)
|
57
|
+
FileSystem.find(one_path) == FileSystem.find(another_path)
|
58
|
+
end
|
59
|
+
|
56
60
|
# Assume nothing is sticky.
|
57
61
|
def sticky?(_path)
|
58
62
|
false
|
@@ -183,7 +187,7 @@ module FakeFS
|
|
183
187
|
options = args[-1].is_a?(Hash) ? args.pop : {}
|
184
188
|
length = args.empty? ? nil : args.shift
|
185
189
|
offset = args.empty? ? 0 : args.shift
|
186
|
-
file = new(path, options)
|
190
|
+
file = new(path, **options)
|
187
191
|
|
188
192
|
raise Errno::ENOENT unless file.exists?
|
189
193
|
raise Errno::EISDIR, path.to_s if directory?(path)
|
@@ -193,11 +197,11 @@ module FakeFS
|
|
193
197
|
file.read(length)
|
194
198
|
end
|
195
199
|
|
196
|
-
def self.readlines(path)
|
200
|
+
def self.readlines(path, chomp: false)
|
197
201
|
file = new(path)
|
198
202
|
if file.exists?
|
199
203
|
FileSystem.find(path).atime = Time.now
|
200
|
-
file.readlines
|
204
|
+
chomp ? file.readlines.map(&:chomp) : file.readlines
|
201
205
|
else
|
202
206
|
raise Errno::ENOENT
|
203
207
|
end
|
@@ -227,6 +231,8 @@ module FakeFS
|
|
227
231
|
end
|
228
232
|
|
229
233
|
if (target = FileSystem.find(source))
|
234
|
+
return 0 if source == dest
|
235
|
+
|
230
236
|
if target.is_a?(FakeFS::FakeSymlink)
|
231
237
|
File.symlink(target.target, dest)
|
232
238
|
else
|
@@ -253,14 +259,15 @@ module FakeFS
|
|
253
259
|
0
|
254
260
|
end
|
255
261
|
|
256
|
-
def self.delete(*
|
257
|
-
|
258
|
-
|
262
|
+
def self.delete(*files)
|
263
|
+
files.each do |file|
|
264
|
+
file_name = (file.class == FakeFS::File ? file.path : file.to_s)
|
265
|
+
raise Errno::ENOENT, file_name unless exists?(file_name)
|
259
266
|
|
260
267
|
FileUtils.rm(file_name)
|
261
268
|
end
|
262
269
|
|
263
|
-
|
270
|
+
files.size
|
264
271
|
end
|
265
272
|
|
266
273
|
class << self
|
@@ -497,8 +504,8 @@ module FakeFS
|
|
497
504
|
true
|
498
505
|
end
|
499
506
|
|
500
|
-
def write(
|
501
|
-
val = super(
|
507
|
+
def write(*args)
|
508
|
+
val = super(*args)
|
502
509
|
@file.mtime = Time.now
|
503
510
|
val
|
504
511
|
end
|
data/lib/fakefs/fileutils.rb
CHANGED
@@ -103,7 +103,7 @@ module FakeFS
|
|
103
103
|
raise Errno::ENOENT, dest.to_s unless File.exist?(dest) || File.exist?(File.dirname(dest))
|
104
104
|
|
105
105
|
# handle `verbose' flag
|
106
|
-
RealFileUtils.cp src, dest, options.merge(noop: true)
|
106
|
+
RealFileUtils.cp src, dest, **options.merge(noop: true)
|
107
107
|
|
108
108
|
# handle `noop' flag
|
109
109
|
return if options[:noop]
|
@@ -145,7 +145,7 @@ module FakeFS
|
|
145
145
|
|
146
146
|
def cp_r(src, dest, options = {})
|
147
147
|
# handle `verbose' flag
|
148
|
-
RealFileUtils.cp_r src, dest, options.merge(noop: true)
|
148
|
+
RealFileUtils.cp_r src, dest, **options.merge(noop: true)
|
149
149
|
|
150
150
|
# handle `noop' flag
|
151
151
|
return if options[:noop]
|
@@ -176,7 +176,7 @@ module FakeFS
|
|
176
176
|
|
177
177
|
def mv(src, dest, options = {})
|
178
178
|
# handle `verbose' flag
|
179
|
-
RealFileUtils.mv src, dest, options.merge(noop: true)
|
179
|
+
RealFileUtils.mv src, dest, **options.merge(noop: true)
|
180
180
|
|
181
181
|
# handle `noop' flag
|
182
182
|
return if options[:noop]
|
data/lib/fakefs/pathname.rb
CHANGED
@@ -109,10 +109,10 @@ module FakeFS
|
|
109
109
|
if File::ALT_SEPARATOR
|
110
110
|
SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}" \
|
111
111
|
"#{Regexp.quote File::SEPARATOR}".freeze
|
112
|
-
SEPARATOR_PAT = /[#{SEPARATOR_LIST}]
|
112
|
+
SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/.freeze
|
113
113
|
else
|
114
114
|
SEPARATOR_LIST = (Regexp.quote File::SEPARATOR).to_s.freeze
|
115
|
-
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}
|
115
|
+
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/.freeze
|
116
116
|
end
|
117
117
|
|
118
118
|
# Return a pathname which the extension of the basename is substituted by
|
@@ -442,9 +442,9 @@ module FakeFS
|
|
442
442
|
def chop_basename(path)
|
443
443
|
base = File.basename(path)
|
444
444
|
if /\A#{SEPARATOR_PAT}?\z/o =~ base
|
445
|
-
|
445
|
+
nil
|
446
446
|
else
|
447
|
-
|
447
|
+
[path[0, path.rindex(base)], base]
|
448
448
|
end
|
449
449
|
end
|
450
450
|
|
data/lib/fakefs/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakefs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2020-
|
15
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bump
|
@@ -29,45 +29,31 @@ dependencies:
|
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 0.5.3
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
32
|
+
name: maxitest
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
35
|
- - "~>"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '3.6'
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - "~>"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: minitest-rg
|
47
|
-
requirement: !ruby/object:Gem::Requirement
|
48
|
-
requirements:
|
49
|
-
- - "~>"
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '5.1'
|
52
|
-
type: :development
|
53
|
-
prerelease: false
|
54
|
-
version_requirements: !ruby/object:Gem::Requirement
|
55
|
-
requirements:
|
56
|
-
- - "~>"
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version: '5.1'
|
44
|
+
version: '3.6'
|
59
45
|
- !ruby/object:Gem::Dependency
|
60
46
|
name: rake
|
61
47
|
requirement: !ruby/object:Gem::Requirement
|
62
48
|
requirements:
|
63
|
-
- - "
|
49
|
+
- - ">="
|
64
50
|
- !ruby/object:Gem::Version
|
65
51
|
version: '10.3'
|
66
52
|
type: :development
|
67
53
|
prerelease: false
|
68
54
|
version_requirements: !ruby/object:Gem::Requirement
|
69
55
|
requirements:
|
70
|
-
- - "
|
56
|
+
- - ">="
|
71
57
|
- !ruby/object:Gem::Version
|
72
58
|
version: '10.3'
|
73
59
|
- !ruby/object:Gem::Dependency
|
@@ -90,14 +76,14 @@ dependencies:
|
|
90
76
|
requirements:
|
91
77
|
- - "~>"
|
92
78
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.
|
79
|
+
version: 0.82.0
|
94
80
|
type: :development
|
95
81
|
prerelease: false
|
96
82
|
version_requirements: !ruby/object:Gem::Requirement
|
97
83
|
requirements:
|
98
84
|
- - "~>"
|
99
85
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.
|
86
|
+
version: 0.82.0
|
101
87
|
description: A fake filesystem. Use it in your tests.
|
102
88
|
email:
|
103
89
|
- chris@ozmm.org
|
@@ -136,14 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
122
|
requirements:
|
137
123
|
- - ">="
|
138
124
|
- !ruby/object:Gem::Version
|
139
|
-
version: 2.
|
125
|
+
version: 2.4.0
|
140
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
127
|
requirements:
|
142
128
|
- - ">="
|
143
129
|
- !ruby/object:Gem::Version
|
144
130
|
version: '0'
|
145
131
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.1.3
|
147
133
|
signing_key:
|
148
134
|
specification_version: 4
|
149
135
|
summary: A fake filesystem. Use it in your tests.
|