fakefs 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
- require "test_helper"
1
+ require 'test_helper'
2
2
 
3
+ # File stat test class
3
4
  class FileStatTest < Test::Unit::TestCase
4
5
  include FakeFS
5
6
 
@@ -25,66 +26,66 @@ class FileStatTest < Test::Unit::TestCase
25
26
 
26
27
  def test_file_stat_init_with_non_existent_file
27
28
  assert_raises(Errno::ENOENT) do
28
- File::Stat.new("/foo")
29
+ File::Stat.new('/foo')
29
30
  end
30
31
  end
31
32
 
32
33
  def test_file_should_be_true_when_file
33
- touch("/foo")
34
- assert File::Stat.new("/foo").file?
34
+ touch('/foo')
35
+ assert File::Stat.new('/foo').file?
35
36
  end
36
37
 
37
38
  def test_symlink_should_be_true_when_symlink
38
- touch("/foo")
39
- ln_s("/foo", "/bar")
39
+ touch('/foo')
40
+ ln_s('/foo', '/bar')
40
41
 
41
- assert File::Stat.new("/bar").symlink?
42
- assert File::Stat.new("/bar").ftype == "link"
42
+ assert File::Stat.new('/bar').symlink?
43
+ assert File::Stat.new('/bar').ftype == 'link'
43
44
  end
44
45
 
45
46
  def test_symlink_should_be_false_when_not_a_symlink
46
- FileUtils.touch("/foo")
47
+ FileUtils.touch('/foo')
47
48
 
48
- assert !File::Stat.new("/foo").symlink?
49
- assert File::Stat.new("/foo").ftype == "file"
49
+ assert !File::Stat.new('/foo').symlink?
50
+ assert File::Stat.new('/foo').ftype == 'file'
50
51
  end
51
52
 
52
53
  def test_should_return_false_for_directory_when_not_a_directory
53
- FileUtils.touch("/foo")
54
+ FileUtils.touch('/foo')
54
55
 
55
- assert !File::Stat.new("/foo").directory?
56
- assert File::Stat.new("/foo").ftype == "file"
56
+ assert !File::Stat.new('/foo').directory?
57
+ assert File::Stat.new('/foo').ftype == 'file'
57
58
  end
58
59
 
59
60
  def test_should_return_true_for_directory_when_a_directory
60
- mkdir "/foo"
61
+ mkdir '/foo'
61
62
 
62
- assert File::Stat.new("/foo").directory?
63
- assert File::Stat.new("/foo").ftype == "directory"
63
+ assert File::Stat.new('/foo').directory?
64
+ assert File::Stat.new('/foo').ftype == 'directory'
64
65
  end
65
66
 
66
67
  def test_writable_is_true
67
- touch("/foo")
68
+ touch('/foo')
68
69
 
69
- assert File::Stat.new("/foo").writable?
70
+ assert File::Stat.new('/foo').writable?
70
71
  end
71
72
 
72
73
  def test_readable_is_true
73
- touch("/foo")
74
+ touch('/foo')
74
75
 
75
- assert File::Stat.new("/foo").readable?
76
+ assert File::Stat.new('/foo').readable?
76
77
  end
77
78
 
78
79
  def test_one_file_has_hard_link
79
- touch "testfile"
80
- assert_equal 1, File.stat("testfile").nlink
80
+ touch 'testfile'
81
+ assert_equal 1, File.stat('testfile').nlink
81
82
  end
82
83
 
83
84
  def test_two_hard_links_show_nlinks_as_two
84
- touch "testfile"
85
- ln "testfile", "testfile.bak"
85
+ touch 'testfile'
86
+ ln 'testfile', 'testfile.bak'
86
87
 
87
- assert_equal 2, File.stat("testfile").nlink
88
+ assert_equal 2, File.stat('testfile').nlink
88
89
  end
89
90
 
90
91
  def test_file_size
@@ -94,38 +95,41 @@ class FileStatTest < Test::Unit::TestCase
94
95
 
95
96
  def test_file_zero?
96
97
  File.open('testfile', 'w') { |f| f << 'test' }
97
- assert !File.stat('testfile').zero?, "testfile has size 4, not zero"
98
+ assert !File.stat('testfile').zero?, 'testfile has size 4, not zero'
98
99
 
99
100
  FileUtils.touch('testfile2')
100
- assert File.stat('testfile2').zero?, "testfile2 has size 0, but stat lied"
101
+ assert File.stat('testfile2').zero?, 'testfile2 has size 0, but stat lied'
101
102
  end
102
103
 
103
104
  def test_touch_modifies_mtime
104
- FileUtils.touch("/foo")
105
- mtime = File.mtime("/foo")
105
+ FileUtils.touch('/foo')
106
+ mtime = File.mtime('/foo')
106
107
 
107
- FileUtils.touch("/foo")
108
- assert File.mtime("/foo") > mtime
108
+ FileUtils.touch('/foo')
109
+ assert File.mtime('/foo') > mtime
109
110
  end
110
111
 
111
112
  def test_writing_to_file_modifies_mtime
112
- FileUtils.touch("/foo")
113
- mtime = File.mtime("/foo")
113
+ FileUtils.touch('/foo')
114
+ mtime = File.mtime('/foo')
114
115
 
115
116
  File.open('/foo', 'w') { |f| f << 'test' }
116
- assert File.mtime("/foo") > mtime
117
+ assert File.mtime('/foo') > mtime
117
118
  end
118
119
 
119
120
  def test_responds_to_world_writable
120
- FileUtils.touch("/foo")
121
- puts File::Stat.new("/foo").world_writable?
122
- assert File::Stat.new("/foo").world_writable? == 0777
121
+ FileUtils.touch('/foo')
122
+ assert File::Stat.new('/foo').world_writable? == 0777
123
+ end
124
+
125
+ def test_responds_to_sticky
126
+ FileUtils.touch('/foo')
127
+ assert !File::Stat.new('/foo').sticky?
123
128
  end
124
129
 
125
130
  def test_responds_to_world_readable
126
- FileUtils.touch("/foo")
127
- puts File::Stat.new("/foo").world_readable?
128
- assert File::Stat.new("/foo").world_readable? == 0777, "#{File::Stat.new("/foo").world_readable?}"
131
+ FileUtils.touch('/foo')
132
+ assert File::Stat.new('/foo').world_readable? == 0777, "#{File::Stat.new('/foo').world_readable?}"
129
133
  end
130
134
 
131
135
  def test_responds_to_world_readable
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
+ # Kernel test class
3
4
  class KernelTest < Test::Unit::TestCase
4
5
  include FakeFS
5
6
  def setup
@@ -25,8 +26,8 @@ class KernelTest < Test::Unit::TestCase
25
26
  def test_fake_kernel_can_create_new_file
26
27
  FakeFS do
27
28
  FileUtils.mkdir_p '/path/to/'
28
- open('/path/to/file', "w") do |f|
29
- f << "test"
29
+ open('/path/to/file', 'w') do |f|
30
+ f << 'test'
30
31
  end
31
32
  assert_kind_of FakeFile, FileSystem.fs['path']['to']['file']
32
33
  end
@@ -38,10 +39,8 @@ class KernelTest < Test::Unit::TestCase
38
39
  File.open('/tmp/a', 'w+') { |f| f.puts 'test' }
39
40
 
40
41
  begin
41
- puts open('/tmp/a').read
42
- rescue Exception => e
43
- puts e
44
- puts e.backtrace
42
+ open('/tmp/a').read
43
+ rescue => e
45
44
  raise e
46
45
  end
47
46
  end
@@ -51,6 +50,4 @@ class KernelTest < Test::Unit::TestCase
51
50
  out = open("|echo 'foo'")
52
51
  assert_equal "foo\n", out.gets
53
52
  end
54
-
55
53
  end
56
-
@@ -1,5 +1,6 @@
1
- require "test_helper"
1
+ require 'test_helper'
2
2
 
3
+ # FakeFS safe test class
3
4
  class FakeFSSafeTest < Test::Unit::TestCase
4
5
  def setup
5
6
  FakeFS.deactivate!
@@ -22,20 +23,20 @@ class FakeFSSafeTest < Test::Unit::TestCase
22
23
  path = 'file.txt'
23
24
 
24
25
  FakeFS do
25
- File.open(path, 'w') { |f| f.write "Yatta!" }
26
- assert File.exists?(path)
26
+ File.open(path, 'w') { |f| f.write 'Yatta!' }
27
+ assert File.exist?(path)
27
28
  end
28
29
 
29
- assert ! File.exists?(path)
30
+ assert !File.exist?(path)
30
31
  end
31
32
 
32
33
  def test_FakeFS_method_returns_value_of_yield
33
34
  result = FakeFS do
34
- File.open('myfile.txt', 'w') { |f| f.write "Yatta!" }
35
+ File.open('myfile.txt', 'w') { |f| f.write 'Yatta!' }
35
36
  File.read('myfile.txt')
36
37
  end
37
38
 
38
- assert_equal result, "Yatta!"
39
+ assert_equal result, 'Yatta!'
39
40
  end
40
41
 
41
42
  def test_FakeFS_method_does_not_deactivate_FakeFS_if_already_activated
@@ -72,9 +73,10 @@ class FakeFSSafeTest < Test::Unit::TestCase
72
73
  def test_FakeFS_method_deactivates_FakeFS_when_block_raises_exception
73
74
  begin
74
75
  FakeFS do
75
- raise 'boom!'
76
+ fail 'boom!'
76
77
  end
77
78
  rescue
79
+ 'Nothing to do'
78
80
  end
79
81
 
80
82
  assert !FakeFS.activated?
@@ -5,10 +5,11 @@ require 'test/unit'
5
5
  begin
6
6
  require 'redgreen'
7
7
  rescue LoadError
8
+ 'Nothing to do'
8
9
  end
9
10
 
10
11
  def act_on_real_fs
11
- raise ArgumentError unless block_given?
12
+ fail ArgumentError unless block_given?
12
13
  FakeFS.deactivate!
13
14
  yield
14
15
  FakeFS.activate!
@@ -4,8 +4,9 @@
4
4
  #
5
5
  # $ RUBYLIB=test ruby test/verify.rb | grep "not implemented"
6
6
 
7
- require "test_helper"
7
+ require 'test_helper'
8
8
 
9
+ # FakeFs verifier test class
9
10
  class FakeFSVerifierTest < Test::Unit::TestCase
10
11
  class_mapping = {
11
12
  RealFile => FakeFS::File,
@@ -18,13 +19,15 @@ class FakeFSVerifierTest < Test::Unit::TestCase
18
19
  class_mapping.each do |real_class, fake_class|
19
20
  real_class.methods.each do |method|
20
21
  define_method "test #{method} class method" do
21
- assert fake_class.respond_to?(method), "#{fake_class}.#{method} not implemented"
22
+ assert fake_class.respond_to?(method),
23
+ "#{fake_class}.#{method} not implemented"
22
24
  end
23
25
  end
24
26
 
25
27
  real_class.instance_methods.each do |method|
26
28
  define_method("test #{method} instance method") do
27
- assert fake_class.instance_methods.include?(method), "#{fake_class}##{method} not implemented"
29
+ assert fake_class.instance_methods.include?(method),
30
+ "#{fake_class}##{method} not implemented"
28
31
  end
29
32
  end
30
33
  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.5.4
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -18,44 +18,58 @@ dependencies:
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.1'
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.1'
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: '2.14'
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: '2.14'
59
+ - !ruby/object:Gem::Dependency
60
+ name: rubocop
61
+ requirement: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - "~>"
64
+ - !ruby/object:Gem::Version
65
+ version: '0.25'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '0.25'
59
73
  description: A fake filesystem. Use it in your tests.
60
74
  email:
61
75
  - chris@ozmm.org
@@ -63,10 +77,11 @@ executables: []
63
77
  extensions: []
64
78
  extra_rdoc_files: []
65
79
  files:
66
- - .autotest
67
- - .gitignore
68
- - .rspec
69
- - .travis.yml
80
+ - ".autotest"
81
+ - ".gitignore"
82
+ - ".rspec"
83
+ - ".rubocop.yml"
84
+ - ".travis.yml"
70
85
  - CONTRIBUTORS
71
86
  - Gemfile
72
87
  - LICENSE
@@ -116,12 +131,12 @@ require_paths:
116
131
  - lib
117
132
  required_ruby_version: !ruby/object:Gem::Requirement
118
133
  requirements:
119
- - - '>='
134
+ - - ">="
120
135
  - !ruby/object:Gem::Version
121
136
  version: '0'
122
137
  required_rubygems_version: !ruby/object:Gem::Requirement
123
138
  requirements:
124
- - - '>='
139
+ - - ">="
125
140
  - !ruby/object:Gem::Version
126
141
  version: '0'
127
142
  requirements: []
@@ -149,4 +164,3 @@ test_files:
149
164
  - test/safe_test.rb
150
165
  - test/test_helper.rb
151
166
  - test/verify.rb
152
- has_rdoc: