fakefs 0.6.5 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +3 -1
- data/CONTRIBUTORS +16 -16
- data/README.markdown +1 -1
- data/Rakefile +2 -2
- data/fakefs.gemspec +2 -0
- data/lib/fakefs/base.rb +7 -5
- data/lib/fakefs/fake/file.rb +11 -10
- data/lib/fakefs/file.rb +21 -0
- data/lib/fakefs/file_system.rb +2 -1
- data/lib/fakefs/version.rb +1 -1
- data/test/dir/tempfile_test.rb +4 -5
- data/test/fake/file/join_test.rb +1 -1
- data/test/fake/file/lstat_test.rb +3 -3
- data/test/fake/file/stat_test.rb +1 -1
- data/test/fake/file/sysseek_test.rb +1 -1
- data/test/fake/file/syswrite_test.rb +1 -1
- data/test/fake/file_test.rb +2 -2
- data/test/fake/symlink_test.rb +4 -4
- data/test/fakefs_test.rb +173 -160
- data/test/file/stat_test.rb +7 -7
- data/test/kernel_test.rb +1 -1
- data/test/pathname_test.rb +3 -3
- data/test/safe_test.rb +7 -7
- data/test/test_helper.rb +13 -12
- data/test/verify.rb +3 -3
- metadata +46 -18
data/test/file/stat_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
# File stat test class
|
4
|
-
class FileStatTest < Test
|
4
|
+
class FileStatTest < Minitest::Test
|
5
5
|
include FakeFS
|
6
6
|
|
7
7
|
def setup
|
@@ -46,14 +46,14 @@ class FileStatTest < Test::Unit::TestCase
|
|
46
46
|
def test_symlink_should_be_false_when_not_a_symlink
|
47
47
|
FileUtils.touch('/foo')
|
48
48
|
|
49
|
-
|
49
|
+
refute File::Stat.new('/foo').symlink?
|
50
50
|
assert File::Stat.new('/foo').ftype == 'file'
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_should_return_false_for_directory_when_not_a_directory
|
54
54
|
FileUtils.touch('/foo')
|
55
55
|
|
56
|
-
|
56
|
+
refute File::Stat.new('/foo').directory?
|
57
57
|
assert File::Stat.new('/foo').ftype == 'file'
|
58
58
|
end
|
59
59
|
|
@@ -95,7 +95,7 @@ class FileStatTest < Test::Unit::TestCase
|
|
95
95
|
|
96
96
|
def test_file_zero?
|
97
97
|
File.open('testfile', 'w') { |f| f << 'test' }
|
98
|
-
|
98
|
+
refute File.stat('testfile').zero?, 'testfile has size 4, not zero'
|
99
99
|
|
100
100
|
FileUtils.touch('testfile2')
|
101
101
|
assert File.stat('testfile2').zero?, 'testfile2 has size 0, but stat lied'
|
@@ -124,7 +124,7 @@ class FileStatTest < Test::Unit::TestCase
|
|
124
124
|
|
125
125
|
def test_responds_to_sticky
|
126
126
|
FileUtils.touch('/foo')
|
127
|
-
|
127
|
+
refute File::Stat.new('/foo').sticky?
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_responds_to_world_readable
|
@@ -144,7 +144,7 @@ class FileStatTest < Test::Unit::TestCase
|
|
144
144
|
if RUBY_VERSION > '1.9'
|
145
145
|
assert File.respond_to?(:realpath)
|
146
146
|
else
|
147
|
-
|
147
|
+
refute File.respond_to?(:realpath)
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
@@ -152,7 +152,7 @@ class FileStatTest < Test::Unit::TestCase
|
|
152
152
|
if RUBY_VERSION >= '1.9.2'
|
153
153
|
assert File.respond_to?(:realdirpath)
|
154
154
|
else
|
155
|
-
|
155
|
+
refute File.respond_to?(:realdirpath)
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
data/test/kernel_test.rb
CHANGED
data/test/pathname_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
# Fake Pathname test class
|
4
|
-
class FakePathnameTest < Test
|
4
|
+
class FakePathnameTest < Minitest::Test
|
5
5
|
include FakeFS
|
6
6
|
|
7
7
|
def setup
|
@@ -17,7 +17,7 @@ class FakePathnameTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_filetest_exists_returns_correct_value
|
20
|
-
|
20
|
+
refute @pathname.exist?
|
21
21
|
|
22
22
|
File.write(@path, '')
|
23
23
|
|
@@ -70,6 +70,6 @@ class FakePathnameTest < Test::Unit::TestCase
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_io_sysopen_is_unsupported
|
73
|
-
|
73
|
+
assert_raises(NotImplementedError) { @pathname.sysopen }
|
74
74
|
end
|
75
75
|
end
|
data/test/safe_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
# FakeFS safe test class
|
4
|
-
class FakeFSSafeTest < Test
|
4
|
+
class FakeFSSafeTest < Minitest::Test
|
5
5
|
def setup
|
6
6
|
FakeFS.deactivate!
|
7
7
|
end
|
@@ -13,7 +13,7 @@ class FakeFSSafeTest < Test::Unit::TestCase
|
|
13
13
|
def test_FakeFS_activated_is_accurate
|
14
14
|
2.times do
|
15
15
|
FakeFS.deactivate!
|
16
|
-
|
16
|
+
refute FakeFS.activated?
|
17
17
|
FakeFS.activate!
|
18
18
|
assert FakeFS.activated?
|
19
19
|
end
|
@@ -27,7 +27,7 @@ class FakeFSSafeTest < Test::Unit::TestCase
|
|
27
27
|
assert File.exist?(path)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
refute File.exist?(path)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_FakeFS_method_returns_value_of_yield
|
@@ -55,19 +55,19 @@ class FakeFSSafeTest < Test::Unit::TestCase
|
|
55
55
|
assert FakeFS.activated?
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
refute FakeFS.activated?
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_FakeFS_method_can_be_nested_with_FakeFS_without
|
62
62
|
FakeFS do
|
63
63
|
assert FakeFS.activated?
|
64
64
|
FakeFS.without do
|
65
|
-
|
65
|
+
refute FakeFS.activated?
|
66
66
|
end
|
67
67
|
assert FakeFS.activated?
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
refute FakeFS.activated?
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_FakeFS_method_deactivates_FakeFS_when_block_raises_exception
|
@@ -79,6 +79,6 @@ class FakeFSSafeTest < Test::Unit::TestCase
|
|
79
79
|
'Nothing to do'
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
refute FakeFS.activated?
|
83
83
|
end
|
84
84
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
2
|
require 'fakefs/safe'
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/rg'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
rescue LoadError
|
8
|
-
'Nothing to do'
|
9
|
-
end
|
10
|
-
|
11
|
-
def act_on_real_fs
|
12
|
-
fail ArgumentError unless block_given?
|
13
|
-
FakeFS.deactivate!
|
14
|
-
yield
|
15
|
-
FakeFS.activate!
|
6
|
+
def act_on_real_fs(&block)
|
7
|
+
FakeFS.without(&block)
|
16
8
|
end
|
17
9
|
|
18
10
|
def capture_stderr
|
@@ -30,3 +22,12 @@ ensure
|
|
30
22
|
# restore FileUtils stderr
|
31
23
|
RealFileUtils.instance_variable_set('@fileutils_output', $stderr)
|
32
24
|
end
|
25
|
+
|
26
|
+
def real_file_sandbox(path = nil)
|
27
|
+
base_path = real_file_sandbox_path
|
28
|
+
path ? File.join(base_path, path) : base_path
|
29
|
+
end
|
30
|
+
|
31
|
+
def real_file_sandbox_path
|
32
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_sandbox'))
|
33
|
+
end
|
data/test/verify.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
require 'test_helper'
|
8
8
|
|
9
9
|
# FakeFs verifier test class
|
10
|
-
class FakeFSVerifierTest < Test
|
10
|
+
class FakeFSVerifierTest < Minitest::Test
|
11
11
|
class_mapping = {
|
12
12
|
RealFile => FakeFS::File,
|
13
13
|
RealFile::Stat => FakeFS::File::Stat,
|
@@ -18,14 +18,14 @@ class FakeFSVerifierTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
class_mapping.each do |real_class, fake_class|
|
20
20
|
real_class.methods.each do |method|
|
21
|
-
define_method "
|
21
|
+
define_method "test_#{method}_class_method" do
|
22
22
|
assert fake_class.respond_to?(method),
|
23
23
|
"#{fake_class}.#{method} not implemented"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
real_class.instance_methods.each do |method|
|
28
|
-
define_method("
|
28
|
+
define_method("test_#{method}_instance_method") do
|
29
29
|
assert fake_class.instance_methods.include?(method),
|
30
30
|
"#{fake_class}##{method} not implemented"
|
31
31
|
end
|
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: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -12,64 +12,92 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-02-
|
15
|
+
date: 2015-02-15 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bundler
|
19
19
|
requirement: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- - ~>
|
21
|
+
- - "~>"
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: '1.3'
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
-
- - ~>
|
28
|
+
- - "~>"
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '1.3'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: rake
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
|
-
- - ~>
|
35
|
+
- - "~>"
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '10.3'
|
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
44
|
version: '10.3'
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: rspec
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
|
-
- - ~>
|
49
|
+
- - "~>"
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '3.1'
|
52
52
|
type: :development
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- - ~>
|
56
|
+
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '3.1'
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rubocop
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
|
-
- - ~>
|
63
|
+
- - "~>"
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0.25'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
|
-
- - ~>
|
70
|
+
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0.25'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: minitest
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '5.5'
|
80
|
+
type: :development
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '5.5'
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: minitest-rg
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '5.1'
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '5.1'
|
73
101
|
description: A fake filesystem. Use it in your tests.
|
74
102
|
email:
|
75
103
|
- chris@ozmm.org
|
@@ -77,11 +105,11 @@ executables: []
|
|
77
105
|
extensions: []
|
78
106
|
extra_rdoc_files: []
|
79
107
|
files:
|
80
|
-
- .autotest
|
81
|
-
- .gitignore
|
82
|
-
- .rspec
|
83
|
-
- .rubocop.yml
|
84
|
-
- .travis.yml
|
108
|
+
- ".autotest"
|
109
|
+
- ".gitignore"
|
110
|
+
- ".rspec"
|
111
|
+
- ".rubocop.yml"
|
112
|
+
- ".travis.yml"
|
85
113
|
- CONTRIBUTORS
|
86
114
|
- Gemfile
|
87
115
|
- LICENSE
|
@@ -133,17 +161,17 @@ require_paths:
|
|
133
161
|
- lib
|
134
162
|
required_ruby_version: !ruby/object:Gem::Requirement
|
135
163
|
requirements:
|
136
|
-
- -
|
164
|
+
- - ">="
|
137
165
|
- !ruby/object:Gem::Version
|
138
166
|
version: '0'
|
139
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
168
|
requirements:
|
141
|
-
- -
|
169
|
+
- - ">="
|
142
170
|
- !ruby/object:Gem::Version
|
143
171
|
version: '0'
|
144
172
|
requirements: []
|
145
173
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.4.5
|
147
175
|
signing_key:
|
148
176
|
specification_version: 4
|
149
177
|
summary: A fake filesystem. Use it in your tests.
|