fakefs 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
+ require 'fakefs/safe'
3
+ require 'test/unit'
4
+
5
+ class FileStatTest < Test::Unit::TestCase
6
+ include FakeFS
7
+
8
+ def setup
9
+ FileSystem.clear
10
+ end
11
+
12
+ def touch(*args)
13
+ FileUtils.touch(*args)
14
+ end
15
+
16
+ def ln_s(*args)
17
+ FileUtils.ln_s(*args)
18
+ end
19
+
20
+ def mkdir(*args)
21
+ Dir.mkdir(*args)
22
+ end
23
+
24
+ def ln(*args)
25
+ File.link(*args)
26
+ end
27
+
28
+ def test_file_stat_init_with_non_existant_file
29
+ assert_raises(Errno::ENOENT) do
30
+ File::Stat.new("/foo")
31
+ end
32
+ end
33
+
34
+ def test_symlink_should_be_true_when_symlink
35
+ touch("/foo")
36
+ ln_s("/foo", "/bar")
37
+
38
+ assert File::Stat.new("/bar").symlink?
39
+ end
40
+
41
+ def test_symlink_should_be_false_when_not_a_symlink
42
+ FileUtils.touch("/foo")
43
+
44
+ assert !File::Stat.new("/foo").symlink?
45
+ end
46
+
47
+ def test_should_return_false_for_directory_when_not_a_directory
48
+ FileUtils.touch("/foo")
49
+
50
+ assert !File::Stat.new("/foo").directory?
51
+ end
52
+
53
+ def test_should_return_true_for_directory_when_a_directory
54
+ mkdir "/foo"
55
+
56
+ assert File::Stat.new("/foo").directory?
57
+ end
58
+
59
+ def test_one_file_has_hard_link
60
+ touch "testfile"
61
+ assert_equal 1, File.stat("testfile").nlink
62
+ end
63
+
64
+ def test_two_hard_links_show_nlinks_as_two
65
+ touch "testfile"
66
+ ln "testfile", "testfile.bak"
67
+
68
+ assert_equal 2, File.stat("testfile").nlink
69
+ end
70
+ end
data/test/safe_test.rb CHANGED
@@ -17,4 +17,26 @@ class FakeFSSafeTest < Test::Unit::TestCase
17
17
 
18
18
  assert ! File.exists?(path)
19
19
  end
20
+
21
+ def test_FakeFS_method_returns_value_of_yield
22
+ result = FakeFS do
23
+ File.open('myfile.txt', 'w') { |f| f.write "Yatta!" }
24
+ File.read('myfile.txt')
25
+ end
26
+
27
+ assert_equal result, "Yatta!"
28
+ end
29
+
30
+ def test_FakeFS_method_deactivates_FakeFS_when_block_raises_exception
31
+ begin
32
+ FakeFS do
33
+ raise 'boom!'
34
+ end
35
+ rescue
36
+ end
37
+
38
+ assert_equal RealFile, File, "File is #{File} (should be #{RealFile})"
39
+ assert_equal RealFileUtils, FileUtils, "FileUtils is #{FileUtils} (should be #{RealFileUtils})"
40
+ assert_equal RealDir, Dir, "Dir is #{Dir} (should be #{RealDir})"
41
+ end
20
42
  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.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-10 00:00:00 -07:00
12
+ date: 2009-10-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -23,6 +23,8 @@ extra_rdoc_files:
23
23
  - LICENSE
24
24
  - README.markdown
25
25
  files:
26
+ - .gitignore
27
+ - CONTRIBUTORS
26
28
  - LICENSE
27
29
  - README.markdown
28
30
  - Rakefile
@@ -36,11 +38,18 @@ files:
36
38
  - lib/fakefs/file_system.rb
37
39
  - lib/fakefs/fileutils.rb
38
40
  - lib/fakefs/safe.rb
41
+ - lib/fakefs/spec_helpers.rb
39
42
  - lib/fakefs/version.rb
43
+ - spec/fakefs/spec_helpers_spec.rb
44
+ - spec/spec.opts
45
+ - spec/spec_helper.rb
46
+ - test/fake/file_test.rb
47
+ - test/fake/symlink_test.rb
40
48
  - test/fakefs_test.rb
49
+ - test/file/stat_test.rb
41
50
  - test/safe_test.rb
42
51
  - test/verify.rb
43
- has_rdoc: true
52
+ has_rdoc: false
44
53
  homepage: http://github.com/defunkt/fakefs
45
54
  licenses: []
46
55
 
@@ -69,6 +78,11 @@ signing_key:
69
78
  specification_version: 3
70
79
  summary: A fake filesystem. Use it in your tests.
71
80
  test_files:
81
+ - spec/fakefs/spec_helpers_spec.rb
82
+ - spec/spec_helper.rb
83
+ - test/fake/file_test.rb
84
+ - test/fake/symlink_test.rb
72
85
  - test/fakefs_test.rb
86
+ - test/file/stat_test.rb
73
87
  - test/safe_test.rb
74
88
  - test/verify.rb