fakefs 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,6 +54,18 @@ class FileStatTest < Test::Unit::TestCase
54
54
  assert File::Stat.new("/foo").directory?
55
55
  end
56
56
 
57
+ def test_writable_is_true
58
+ touch("/foo")
59
+
60
+ assert File::Stat.new("/foo").writable?
61
+ end
62
+
63
+ def test_readable_is_true
64
+ touch("/foo")
65
+
66
+ assert File::Stat.new("/foo").readable?
67
+ end
68
+
57
69
  def test_one_file_has_hard_link
58
70
  touch "testfile"
59
71
  assert_equal 1, File.stat("testfile").nlink
@@ -70,4 +82,28 @@ class FileStatTest < Test::Unit::TestCase
70
82
  File.open('testfile', 'w') { |f| f << 'test' }
71
83
  assert_equal 4, File.stat('testfile').size
72
84
  end
85
+
86
+ def test_file_zero?
87
+ File.open('testfile', 'w') { |f| f << 'test' }
88
+ assert !File.stat('testfile').zero?, "testfile has size 4, not zero"
89
+
90
+ FileUtils.touch('testfile2')
91
+ assert File.stat('testfile2').zero?, "testfile2 has size 0, but stat lied"
92
+ end
93
+
94
+ def test_touch_modifies_mtime
95
+ FileUtils.touch("/foo")
96
+ mtime = File.mtime("/foo")
97
+
98
+ FileUtils.touch("/foo")
99
+ assert File.mtime("/foo") > mtime
100
+ end
101
+
102
+ def test_writing_to_file_modifies_mtime
103
+ FileUtils.touch("/foo")
104
+ mtime = File.mtime("/foo")
105
+
106
+ File.open('/foo', 'w') { |f| f << 'test' }
107
+ assert File.mtime("/foo") > mtime
108
+ end
73
109
  end
@@ -9,6 +9,15 @@ class FakeFSSafeTest < Test::Unit::TestCase
9
9
  FakeFS.activate!
10
10
  end
11
11
 
12
+ def test_FakeFS_activated_is_accurate
13
+ 2.times do
14
+ FakeFS.deactivate!
15
+ assert !FakeFS.activated?
16
+ FakeFS.activate!
17
+ assert FakeFS.activated?
18
+ end
19
+ end
20
+
12
21
  def test_FakeFS_method_does_not_intrude_on_global_namespace
13
22
  path = 'file.txt'
14
23
 
@@ -29,6 +38,37 @@ class FakeFSSafeTest < Test::Unit::TestCase
29
38
  assert_equal result, "Yatta!"
30
39
  end
31
40
 
41
+ def test_FakeFS_method_does_not_deactivate_FakeFS_if_already_activated
42
+ FakeFS.activate!
43
+ FakeFS {}
44
+
45
+ assert FakeFS.activated?
46
+ end
47
+
48
+ def test_FakeFS_method_can_be_nested
49
+ FakeFS do
50
+ assert FakeFS.activated?
51
+ FakeFS do
52
+ assert FakeFS.activated?
53
+ end
54
+ assert FakeFS.activated?
55
+ end
56
+
57
+ assert !FakeFS.activated?
58
+ end
59
+
60
+ def test_FakeFS_method_can_be_nested_with_FakeFS_without
61
+ FakeFS do
62
+ assert FakeFS.activated?
63
+ FakeFS.without do
64
+ assert !FakeFS.activated?
65
+ end
66
+ assert FakeFS.activated?
67
+ end
68
+
69
+ assert !FakeFS.activated?
70
+ end
71
+
32
72
  def test_FakeFS_method_deactivates_FakeFS_when_block_raises_exception
33
73
  begin
34
74
  FakeFS do
@@ -37,8 +77,6 @@ class FakeFSSafeTest < Test::Unit::TestCase
37
77
  rescue
38
78
  end
39
79
 
40
- assert_equal RealFile, File, "File is #{File} (should be #{RealFile})"
41
- assert_equal RealFileUtils, FileUtils, "FileUtils is #{FileUtils} (should be #{RealFileUtils})"
42
- assert_equal RealDir, Dir, "Dir is #{Dir} (should be #{RealDir})"
80
+ assert !FakeFS.activated?
43
81
  end
44
82
  end
@@ -5,4 +5,11 @@ require 'test/unit'
5
5
  begin
6
6
  require 'redgreen'
7
7
  rescue LoadError
8
- end
8
+ end
9
+
10
+ def act_on_real_fs
11
+ raise ArgumentError unless block_given?
12
+ FakeFS.deactivate!
13
+ yield
14
+ FakeFS.activate!
15
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fakefs
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
4
5
  prerelease:
5
- version: 0.4.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Chris Wanstrath
9
9
  - Scott Taylor
10
10
  - Jeff Hodges
@@ -12,68 +12,70 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
-
16
- date: 2011-09-05 00:00:00 -04:00
17
- default_executable:
18
- dependencies:
19
- - !ruby/object:Gem::Dependency
15
+ date: 2012-11-14 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
20
18
  name: rspec
21
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: !ruby/object:Gem::Requirement
22
20
  none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: "0"
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
27
25
  type: :development
28
26
  prerelease: false
29
- version_requirements: *id001
30
- - !ruby/object:Gem::Dependency
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ - !ruby/object:Gem::Dependency
31
34
  name: jeweler
32
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
33
36
  none: false
34
- requirements:
35
- - - ">="
36
- - !ruby/object:Gem::Version
37
- version: "0"
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
38
41
  type: :development
39
42
  prerelease: false
40
- version_requirements: *id002
41
- - !ruby/object:Gem::Dependency
42
- name: sdoc-helpers
43
- requirement: &id003 !ruby/object:Gem::Requirement
43
+ version_requirements: !ruby/object:Gem::Requirement
44
44
  none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: "0"
49
- type: :development
50
- prerelease: false
51
- version_requirements: *id003
52
- - !ruby/object:Gem::Dependency
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ - !ruby/object:Gem::Dependency
53
50
  name: rdiscount
54
- requirement: &id004 !ruby/object:Gem::Requirement
51
+ requirement: !ruby/object:Gem::Requirement
55
52
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: "0"
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
60
57
  type: :development
61
58
  prerelease: false
62
- version_requirements: *id004
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
63
65
  description: A fake filesystem. Use it in your tests.
64
66
  email: chris@ozmm.org
65
67
  executables: []
66
-
67
68
  extensions: []
68
-
69
- extra_rdoc_files:
69
+ extra_rdoc_files:
70
70
  - LICENSE
71
71
  - README.markdown
72
- files:
72
+ files:
73
73
  - .autotest
74
74
  - .rspec
75
+ - .travis.yml
75
76
  - CONTRIBUTORS
76
77
  - Gemfile
78
+ - Gemfile.lock
77
79
  - LICENSE
78
80
  - README.markdown
79
81
  - Rakefile
@@ -88,6 +90,7 @@ files:
88
90
  - lib/fakefs/file_system.rb
89
91
  - lib/fakefs/file_test.rb
90
92
  - lib/fakefs/fileutils.rb
93
+ - lib/fakefs/pathname.rb
91
94
  - lib/fakefs/safe.rb
92
95
  - lib/fakefs/spec_helpers.rb
93
96
  - lib/fakefs/version.rb
@@ -106,33 +109,31 @@ files:
106
109
  - test/safe_test.rb
107
110
  - test/test_helper.rb
108
111
  - test/verify.rb
109
- has_rdoc: true
110
112
  homepage: http://github.com/defunkt/fakefs
111
113
  licenses: []
112
-
113
114
  post_install_message:
114
115
  rdoc_options: []
115
-
116
- require_paths:
116
+ require_paths:
117
117
  - lib
118
- required_ruby_version: !ruby/object:Gem::Requirement
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: "0"
124
- required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
125
+ - 0
126
+ hash: 4221533071311333318
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
128
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- version: "0"
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
130
133
  requirements: []
131
-
132
134
  rubyforge_project:
133
- rubygems_version: 1.6.2
135
+ rubygems_version: 1.8.24
134
136
  signing_key:
135
137
  specification_version: 3
136
138
  summary: A fake filesystem. Use it in your tests.
137
139
  test_files: []
138
-