fakefs 1.2.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b44fd4b36d76a0fd4201c8d65438b10f916e19ad111b857f1b4b83269c3a3911
4
- data.tar.gz: 9c2ae1a1a131116c1aac45e4bac9791a55c430862dc24d85c97053656ecea050
3
+ metadata.gz: 0e9d642f0d0255622007821c7433fd416e328aa50dc2308c866d00922db0ae48
4
+ data.tar.gz: 3f0a76cbd3f0dbf65bf66be32e54dcbffc33c05be84c74f28136e7e37812066e
5
5
  SHA512:
6
- metadata.gz: 8d092e26a0b3ac14a75807243fae5d5e297fed1b24884182553fc5cd8b943cb867e73aac2a16c461abe2279db1102190b94db33120b0292560ad768037c319ab
7
- data.tar.gz: e73736a37d2b9476af943802b4496d751c1aba4a6ba9ce20aca77cbed665a2ddd9e294e95d89b07c180addfc4c3c54e895afd04538f39d8cda538f4faa6b66c6
6
+ metadata.gz: f9635356aa39838dfaf30fb3768754edb74073fccba55e348644402ecd14219ffd3252f08910721c6eec0f03a491cbf5c09575016a0656e7bae826c458980692
7
+ data.tar.gz: 3be473ee1b024b6927b65fc1b9e1f0a1594e7f45f8da875b25b8897578b611e7ea44c40e5d16d59ee4e31eca7b780c32f07ef28d509179ff70dc723b6db5217e
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- FakeFS [![build status](https://travis-ci.org/fakefs/fakefs.svg?branch=master)](https://travis-ci.org/fakefs/fakefs)
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://travis-ci.org/fakefs/fakefs>
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/
@@ -85,14 +85,14 @@ module FakeFS
85
85
  FileSystem.delete(string)
86
86
  end
87
87
 
88
- def self.entries(dirname, _opts = {})
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, opts = {})
95
- entries(dirname, **opts) - ['.', '..']
94
+ def self.children(dirname, _options = nil)
95
+ entries(dirname) - ['.', '..']
96
96
  end
97
97
 
98
98
  def self.each_child(dirname, &_block)
@@ -120,11 +120,13 @@ module FakeFS
120
120
  def self.glob(pattern, flags = 0, &block)
121
121
  matches_for_pattern = lambda do |matcher|
122
122
  [FileSystem.find(matcher, flags, true) || []].flatten.map do |e|
123
- if Dir.pwd.match(%r{\A/?\z}) ||
124
- !e.to_s.match(%r{\A#{Dir.pwd}/?})
123
+ pwd = Dir.pwd
124
+ pwd_regex = %r{\A#{pwd.gsub('+') { '\+' }}/?}
125
+ if pwd.match(%r{\A/?\z}) ||
126
+ !e.to_s.match(pwd_regex)
125
127
  e.to_s
126
128
  else
127
- e.to_s.match(%r{\A#{Dir.pwd}/?}).post_match
129
+ e.to_s.match(pwd_regex).post_match
128
130
  end
129
131
  end.sort
130
132
  end
@@ -198,7 +200,9 @@ module FakeFS
198
200
  opts = {}
199
201
  end
200
202
  tmpdir, = *rest
201
- tmpdir ||= self.tmpdir # rubocop:disable Style/RedundantSelf
203
+ tmpdir ||= self.tmpdir
204
+ Dir.mkdir(tmpdir) unless Dir.exist?(tmpdir)
205
+
202
206
  n = nil
203
207
  begin
204
208
  path = File.join(tmpdir, make_tmpname(basename, n))
@@ -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
@@ -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(*file_names)
257
- file_names.each do |file_name|
258
- raise Errno::ENOENT, file_name.to_s unless exists?(file_name)
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
- file_names.size
270
+ files.size
264
271
  end
265
272
 
266
273
  class << self
@@ -66,11 +66,11 @@ module FakeFS
66
66
  alias remove rm
67
67
 
68
68
  def rm_f(list, options = {})
69
- rm(list, **options.merge(force: true))
69
+ rm(list, options.merge(force: true))
70
70
  end
71
71
 
72
72
  def rm_rf(list, options = {})
73
- rm_r(list, **options.merge(force: true))
73
+ rm_r(list, options.merge(force: true))
74
74
  end
75
75
  alias rmtree rm_rf
76
76
  alias safe_unlink rm_f
@@ -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
- return nil
445
+ nil
446
446
  else
447
- return path[0, path.rindex(base)], base
447
+ [path[0, path.rindex(base)], base]
448
448
  end
449
449
  end
450
450
 
@@ -1,7 +1,7 @@
1
1
  module FakeFS
2
2
  # Version module
3
3
  module Version
4
- VERSION = '1.2.0'.freeze
4
+ VERSION = '1.3.1'.freeze
5
5
 
6
6
  def self.to_s
7
7
  VERSION
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.2.0
4
+ version: 1.3.1
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-03-24 00:00:00.000000000 Z
15
+ date: 2020-12-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bump
@@ -29,33 +29,19 @@ dependencies:
29
29
  - !ruby/object:Gem::Version
30
30
  version: 0.5.3
31
31
  - !ruby/object:Gem::Dependency
32
- name: minitest
32
+ name: maxitest
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
35
  - - "~>"
36
36
  - !ruby/object:Gem::Version
37
- version: '5.5'
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: '5.5'
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
@@ -90,14 +76,14 @@ dependencies:
90
76
  requirements:
91
77
  - - "~>"
92
78
  - !ruby/object:Gem::Version
93
- version: 0.58.1
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.58.1
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.3.0
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.0.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.