fakefs 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,4 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
- require 'fakefs/safe'
3
- require 'test/unit'
1
+ require "test_helper"
4
2
 
5
3
  class FileStatTest < Test::Unit::TestCase
6
4
  include FakeFS
@@ -67,4 +65,9 @@ class FileStatTest < Test::Unit::TestCase
67
65
 
68
66
  assert_equal 2, File.stat("testfile").nlink
69
67
  end
68
+
69
+ def test_file_size
70
+ File.open('testfile', 'w') { |f| f << 'test' }
71
+ assert_equal 4, File.stat('testfile').size
72
+ end
70
73
  end
data/test/safe_test.rb CHANGED
@@ -1,12 +1,14 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
- require 'fakefs/safe'
3
- require 'test/unit'
1
+ require "test_helper"
4
2
 
5
3
  class FakeFSSafeTest < Test::Unit::TestCase
6
4
  def setup
7
5
  FakeFS.deactivate!
8
6
  end
9
7
 
8
+ def teardown
9
+ FakeFS.activate!
10
+ end
11
+
10
12
  def test_FakeFS_method_does_not_intrude_on_global_namespace
11
13
  path = '/path/to/file.txt'
12
14
 
@@ -26,7 +28,7 @@ class FakeFSSafeTest < Test::Unit::TestCase
26
28
 
27
29
  assert_equal result, "Yatta!"
28
30
  end
29
-
31
+
30
32
  def test_FakeFS_method_deactivates_FakeFS_when_block_raises_exception
31
33
  begin
32
34
  FakeFS do
@@ -34,9 +36,9 @@ class FakeFSSafeTest < Test::Unit::TestCase
34
36
  end
35
37
  rescue
36
38
  end
37
-
39
+
38
40
  assert_equal RealFile, File, "File is #{File} (should be #{RealFile})"
39
- assert_equal RealFileUtils, FileUtils, "FileUtils is #{FileUtils} (should be #{RealFileUtils})"
41
+ assert_equal RealFileUtils, FileUtils, "FileUtils is #{FileUtils} (should be #{RealFileUtils})"
40
42
  assert_equal RealDir, Dir, "Dir is #{Dir} (should be #{RealDir})"
41
- end
43
+ end
42
44
  end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'fakefs/safe'
3
+ require 'test/unit'
4
+
5
+ begin
6
+ require 'redgreen'
7
+ rescue LoadError
8
+ end
data/test/verify.rb CHANGED
@@ -2,26 +2,30 @@
2
2
  #
3
3
  # USAGE
4
4
  #
5
- # $ ruby test/verify.rb | grep "not implemented"
6
- require 'fakefs'
7
- require 'test/unit'
8
-
5
+ # $ RUBYLIB=test ruby test/verify.rb | grep "not implemented"
6
+
7
+ require "test_helper"
8
+
9
9
  class FakeFSVerifierTest < Test::Unit::TestCase
10
- (RealFile.methods - Class.new.methods).each do |name|
11
- define_method("test #{name} class method") do
12
- assert File.respond_to?(name), "File.#{name} not implemented"
10
+ class_mapping = {
11
+ RealFile => FakeFS::File,
12
+ RealFile::Stat => FakeFS::File::Stat,
13
+ RealFileUtils => FakeFS::FileUtils,
14
+ RealDir => FakeFS::Dir,
15
+ RealFileTest => FakeFS::FileTest
16
+ }
17
+
18
+ class_mapping.each do |real_class, fake_class|
19
+ real_class.methods.each do |method|
20
+ define_method "test #{method} class method" do
21
+ assert fake_class.respond_to?(method), "#{fake_class}.#{method} not implemented"
22
+ end
13
23
  end
14
- end
15
-
16
- (RealFile.instance_methods - Enumerable.instance_methods).each do |name|
17
- define_method("test #{name} instance method") do
18
- assert File.instance_methods.include?(name), "File##{name} not implemented"
19
- end
20
- end
21
-
22
- (RealFileUtils.methods - Class.new.methods).each do |name|
23
- define_method("test #{name} module method") do
24
- assert FileUtils.respond_to?(name), "FileUtils.#{name} not implemented"
24
+
25
+ real_class.instance_methods.each do |method|
26
+ define_method("test #{method} instance method") do
27
+ assert fake_class.instance_methods.include?(method), "#{fake_class}##{name} not implemented"
28
+ end
25
29
  end
26
30
  end
27
31
  end
metadata CHANGED
@@ -1,15 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakefs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Chris Wanstrath
14
+ - Scott Taylor
15
+ - Jeff Hodges
16
+ - Pat Nakajima
8
17
  autorequire:
9
18
  bindir: bin
10
19
  cert_chain: []
11
20
 
12
- date: 2009-10-30 00:00:00 -07:00
21
+ date: 2010-12-18 00:00:00 -05:00
13
22
  default_executable:
14
23
  dependencies: []
15
24
 
@@ -23,11 +32,13 @@ extra_rdoc_files:
23
32
  - LICENSE
24
33
  - README.markdown
25
34
  files:
35
+ - .autotest
26
36
  - .gitignore
27
37
  - CONTRIBUTORS
28
38
  - LICENSE
29
39
  - README.markdown
30
40
  - Rakefile
41
+ - fakefs.gemspec
31
42
  - lib/fakefs.rb
32
43
  - lib/fakefs/base.rb
33
44
  - lib/fakefs/dir.rb
@@ -36,6 +47,7 @@ files:
36
47
  - lib/fakefs/fake/symlink.rb
37
48
  - lib/fakefs/file.rb
38
49
  - lib/fakefs/file_system.rb
50
+ - lib/fakefs/file_test.rb
39
51
  - lib/fakefs/fileutils.rb
40
52
  - lib/fakefs/safe.rb
41
53
  - lib/fakefs/spec_helpers.rb
@@ -43,13 +55,18 @@ files:
43
55
  - spec/fakefs/spec_helpers_spec.rb
44
56
  - spec/spec.opts
45
57
  - spec/spec_helper.rb
58
+ - test/fake/file/lstat_test.rb
59
+ - test/fake/file/stat_test.rb
60
+ - test/fake/file/sysseek_test.rb
61
+ - test/fake/file/syswrite_test.rb
46
62
  - test/fake/file_test.rb
47
63
  - test/fake/symlink_test.rb
48
64
  - test/fakefs_test.rb
49
65
  - test/file/stat_test.rb
50
66
  - test/safe_test.rb
67
+ - test/test_helper.rb
51
68
  - test/verify.rb
52
- has_rdoc: false
69
+ has_rdoc: true
53
70
  homepage: http://github.com/defunkt/fakefs
54
71
  licenses: []
55
72
 
@@ -59,30 +76,41 @@ rdoc_options:
59
76
  require_paths:
60
77
  - lib
61
78
  required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
62
80
  requirements:
63
81
  - - ">="
64
82
  - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
65
86
  version: "0"
66
- version:
67
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
68
89
  requirements:
69
90
  - - ">="
70
91
  - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
71
95
  version: "0"
72
- version:
73
96
  requirements: []
74
97
 
75
98
  rubyforge_project:
76
- rubygems_version: 1.3.5
99
+ rubygems_version: 1.3.7
77
100
  signing_key:
78
101
  specification_version: 3
79
102
  summary: A fake filesystem. Use it in your tests.
80
103
  test_files:
81
104
  - spec/fakefs/spec_helpers_spec.rb
82
105
  - spec/spec_helper.rb
106
+ - test/fake/file/lstat_test.rb
107
+ - test/fake/file/stat_test.rb
108
+ - test/fake/file/sysseek_test.rb
109
+ - test/fake/file/syswrite_test.rb
83
110
  - test/fake/file_test.rb
84
111
  - test/fake/symlink_test.rb
85
112
  - test/fakefs_test.rb
86
113
  - test/file/stat_test.rb
87
114
  - test/safe_test.rb
115
+ - test/test_helper.rb
88
116
  - test/verify.rb