fakefs 0.6.1 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDg1ODBmOTkwMzAxY2RjNzU1YzFmOTJlZDU4MmQ5YTZiMWIyMzZiMg==
4
+ OTI3MWUyNGQ3M2Q0MWQ3YmQ5ZjIzYTM1MTcxZDE2MTI5NzYxMDBlMQ==
5
5
  data.tar.gz: !binary |-
6
- N2Y3OGI0ZDY4YjRmNTA1ZmYyZDcyMmI5MjE0NjI2Y2Y0NDQ2NjM2OA==
6
+ Y2ZhNGRjYjU1N2MyZDUwN2QxNWQ0OGQ2NmZhM2M0MzgyZDZmM2VhNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTE1NTY1NDM0ZWE5NGViNjdjNTU3M2Y4MTNjZTcwMTdiN2I3ODYxZmMyNjg5
10
- ZGNkNjliOGQ2OWUxZGE0MDY4OTgwMjljN2M4MmQwYjMzOWM5MDdjZDgzYmJi
11
- Mzc5NGYyN2M0YWEzZjhlMDM2NTU1YTExYTJiOWZiZDljNmJiODM=
9
+ MmU5M2M0OGJjOTFjMzJjZTdlY2Q2NzI4YzI1MWE2NWU2MTI3NDI0MTZjYTJh
10
+ ZDEyZjEzY2E3NmNiNmEzNDhkZGY4MzIyMzU4MDAxMTZjYjFhMjkwZGU1Njkw
11
+ ZjM5ZDI0ZTE2MTMwN2Q3NTJjY2VhZjczNGQ4M2Y0OTg3MTJjNzY=
12
12
  data.tar.gz: !binary |-
13
- NTNiZTFjNjU5YWRjZDA3MzZiZDY3ZmQ0YjhlMDY3NWVjMjM3MzY1NGNjMjQ0
14
- ZDA0OWNmNzRmMTRmYTg5YjI1NzNjZDg4Yjc4YjAyZGUyZjc1ZWY5NTBlN2Q0
15
- NWNjMTQxYmJkYzMzZGNlMjRhNjdkMDI5MWFjOTJlZGJlNzA4ODk=
13
+ NGJjODhjMjFiZmUyYTMxZjVlZGQ5NjlmY2IwNDk4NjA5NTFjZTNiYjk0Mjhl
14
+ YTQ3NGYwNGVkOWM5ZTM4YTZmNzA2YjAxN2E4YTY1Zjg2MzAxMTdiNTg1OWY1
15
+ NTdjMTBiNjViNzAwNDM0NWY2ZDllODQxM2ZjYmJjN2Y5YWYyOWE=
@@ -7,21 +7,19 @@ AllCops:
7
7
  Exclude:
8
8
  - files/**/*
9
9
  - templates/**/*
10
+ - etc/**/*
10
11
  MethodLength:
11
12
  Exclude:
12
13
  - lib/**/*
13
14
  - test/**/*.rb
14
15
  - spec/**/*.rb
15
16
  ClassLength:
16
- Exclude:
17
- - lib/**/*
18
- - test/**/*
17
+ Enabled: false
19
18
  LineLength:
20
19
  Exclude:
21
20
  - test/**/*
22
21
  ParameterLists:
23
- Exclude:
24
- - lib/**/*
22
+ Enabled: false
25
23
  Metrics/CyclomaticComplexity:
26
24
  Severity: warning
27
25
  Max: 20
@@ -29,22 +27,19 @@ Metrics/PerceivedComplexity:
29
27
  Severity: warning
30
28
  Max: 20
31
29
  Lint/Eval:
32
- Exclude:
33
- - lib/**/*
30
+ Enabled: false
34
31
  Metrics/BlockNesting:
35
32
  Severity: warning
36
33
  Max: 4
34
+ Metrics/AbcSize:
35
+ Enabled: false
37
36
  Style/PredicateName:
38
37
  Exclude:
39
38
  - lib/fakefs/file.rb
40
39
  Style/MethodName:
41
- Exclude:
42
- - lib/**/*.rb
43
- - test/**/*.rb
40
+ Enabled: false
44
41
  Style/ModuleFunction:
45
- Exclude:
46
- - lib/**/*.rb
47
- - test/**/*.rb
42
+ Enabled: false
48
43
  TrivialAccessors:
49
44
  Enabled: true
50
45
  ExactNameMatch: true
@@ -1,73 +1,92 @@
1
1
  Scott Taylor <scott@railsnewbie.com>
2
+ Pierre RAMBAUD <pierre.rambaud@numergy.com>
2
3
  Pat Nakajima <patnakajima@gmail.com>
3
4
  Chris Wanstrath <chris@ozmm.org>
4
5
  Lukas Oberhuber <lukaso@gmail.com>
6
+ Brian Donovan <donovan@squareup.com>
5
7
  Myles Eftos <myles@madpilot.com.au>
6
8
  Jeff Hodges <jeff@somethingsimilar.com>
9
+ Pierre RAMBAUD <pierre.rambaud86@gmail.com>
7
10
  Morten Møller Riis <mortenmoellerriis@gmail.com>
8
11
  Matt Freels <matt@freels.name>
9
12
  Eero Saynatkari <projects@kittensoft.org>
10
13
  Andres Riofrio <riofrios@gmail.com>
14
+ Brian Donovan <me@brian-donovan.com>
15
+ Jacob Evans <jacob@dekz.net>
11
16
  Víctor Martínez <knoopx@gmail.com>
12
- Brian Donovan <donovan@squareup.com>
13
17
  Mariusz Pietrzyk <wijet@wijet.pl>
14
18
  John Firebaugh <john.firebaugh@gmail.com>
15
19
  Sebastian Boehm <sebastian@sometimesfood.org>
20
+ Carlos Pardo <cpardo@altavistaed.com>
16
21
  AlphaHydrae <hydrae.alpha@gmail.com>
17
22
  Nick Quaranto <nick@quaran.to>
23
+ Dan Duvall <dduvall@wikimedia.org>
24
+ Toby Ovod-Everett <toby@ovod-everett.org>
18
25
  Aaron Suggs <aaron@ktheory.com>
19
26
  Victor Costan <costan@gmail.com>
20
27
  Mateusz Juraszek <meceo00@gmail.com>
21
28
  Eric MSP Veith <eveith@wwweb-library.net>
29
+ Leigh Caplan <lcaplan@onehub.com>
22
30
  Daniel Dyba <daniel.dyba@gmail.com>
23
31
  Maarten Hoogendoorn <maarten@moretea.nl>
24
32
  Jon Yurek <jyurek@thoughtbot.com>
25
33
  Jared Luxenberg <jared@jaredlux.com>
26
34
  DSIW <dsiw@dsiw-it.de>
27
- Greg Campbell <gtcampbell@gmail.com>
28
- Lars Gierth <lars.gierth@gmail.com>
29
35
  doc75 <github@virlet.org>
36
+ Lars Gierth <lars.gierth@gmail.com>
37
+ Greg Campbell <gtcampbell@gmail.com>
30
38
  marano <thiagomarano@gmail.com>
31
39
  Ben Mabey <ben@benmabey.com>
32
- Jorge Orlando Munoz <jmunoz@altavistaed.com>
33
40
  Mark <mark@amerine.net>
41
+ Jorge Orlando Munoz <jmunoz@altavistaed.com>
34
42
  Sam Goldstein <sam@aboutus.org>
43
+ Adam Alboyadjian <adam@vistahigherlearning.com>
44
+ Rick Salevsky <rsalevsky@suse.com>
35
45
  Scott Petersen <petersen@centtech.com>
36
- Matt Todd <chiology@gmail.com>
46
+ Ryan McGeary <ryan@mcgeary.org>
37
47
  Emil Soman <emil.soman@gmail.com>
48
+ Matt Todd <chiology@gmail.com>
38
49
  Noah Paessel <knowuh@gmail.com>
39
- Ryan McGeary <ryan@mcgeary.org>
40
50
  dmathieu <42@dmathieu.com>
41
51
  Oleg Sukhodolsky <os97673@gmail.com>
42
- Adam Alboyadjian <adam@vistahigherlearning.com>
52
+ Winston Lee <lee.winston@gmail.com>
53
+ Radek Simko <radek.simko@gmail.com>
54
+ Grayson Wright <wright.grayson@gmail.com>
55
+ Zequez <zequez@gmail.com>
43
56
  jameswilding <james@jameswilding.net>
44
57
  Ed Ruder <ed@squareup.com>
45
58
  Tymon Tobolski <i@teamon.eu>
46
59
  Benjamin Oakes <hello@benjaminoakes.com>
47
60
  Scott Barron <scott@elitists.net>
61
+ Eric Daspet <eric.daspet@survol.fr>
48
62
  Andrius Chamentauskas <andrius.chamentauskas@gmail.com>
49
- W. Andrew Loe III <andrew@andrewloe.com>
50
- Toby Ovod-Everett <toby@ovod-everett.org>
51
63
  Xavier Shay <xavier@squareup.com>
64
+ W. Andrew Loe III <andrew@andrewloe.com>
65
+ Matt Hoyle <matt@deployable.co>
52
66
  Travis Herrick <travis@carbonfive.com>
53
- rambutan <usul@usul-HP-EliteBook-8460p.(none)>
54
67
  Keita Urashima <ursm@ursm.jp>
55
- Matthew Morgan <lytithwyn@gmail.com>
56
- andrea longhi <andrea@spaghetticode.it>
68
+ rambutan <usul@usul-HP-EliteBook-8460p.(none)>
57
69
  msassak <msassak@gmail.com>
70
+ andrea longhi <andrea@spaghetticode.it>
71
+ = <gokulnath@mobme.in>
72
+ Matthew Morgan <lytithwyn@gmail.com>
58
73
  David Reese <david@whatcould.com>
59
- timo3377 <tim.linquist@gmail.com>
60
74
  Andrius Chamentauskas <sinsiliux@gmail.com>
75
+ timo3377 <tim.linquist@gmail.com>
61
76
  Michael Scherer <misc@zarb.org>
62
77
  Matt Rogers <mattrogers@sbcglobal.net>
78
+ Jakub Jirutka <jakub@jirutka.cz>
79
+ Paolo Gianrossi <paolino.gianrossi@gmail.com>
63
80
  Mislav Marohnić <mislav.marohnic@gmail.com>
64
- Andrew Ryan <nerdrew@gmail.com>
65
81
  Rob Sanheim <rsanheim@gmail.com>
66
- Chris Knadler <takeshi91k@gmail.com>
67
- Chris Wanstrath <chris@github.com>
82
+ Andrew Ryan <nerdrew@gmail.com>
68
83
  Toon Willems <willemstoon@gmail.com>
69
84
  Ryan Scott Lewis <ryanscottlewis@lewis-software.com>
85
+ Chris Knadler <takeshi91k@gmail.com>
86
+ Chris Wanstrath <chris@github.com>
70
87
  Yuta Shimizu <pachirel@gmail.com>
88
+ Sven Riedel <sr@gimp.org>
89
+ Dane O'Connor <dane.oconnor@gmail.com>
71
90
  Jordi Massaguer Pla <jmassaguerpla@suse.de>
91
+ Maria Shaldibina <mariash@pivotallabs.com>
72
92
  Benjamin Fleischer <github@benjaminfleischer.com>
73
- Brian Donovan <me@brian-donovan.com>
@@ -170,4 +170,4 @@ Releasing
170
170
 
171
171
  1. Update version in lib/fakefs/version.rb
172
172
  2. Commit it
173
- 3. run rake publish
173
+ 3. run `rake publish`
data/Rakefile CHANGED
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'test')
3
3
 
4
4
  require 'bundler/setup'
5
5
  require 'rake/testtask'
6
+ require File.expand_path(File.join(File.dirname(__FILE__), "lib", "fakefs", "version"))
6
7
 
7
8
  Rake::TestTask.new do |t|
8
9
  t.libs << 'test'
@@ -26,10 +27,10 @@ rescue LoadError
26
27
  puts "Rubocop task can't be loaded. `gem install rubocop`"
27
28
  end
28
29
 
29
- task default: [:test, :spec]
30
+ task default: [:test, :spec, :rubocop]
30
31
 
31
32
  desc 'Push a new version to rubygems.org'
32
- task :publish => [:test, :spec, :update_contributors, :release]
33
+ task :publish => [:test, :spec, :update_contributors, :tag, :release, :push]
33
34
 
34
35
  desc 'Update contributors'
35
36
  task :update_contributors do
@@ -45,6 +46,16 @@ end
45
46
  desc 'Release a new version'
46
47
  task :release do
47
48
  sh "gem build fakefs.gemspec"
48
-
49
49
  sh "gem push fakefs-*.gem"
50
- end
50
+ end
51
+
52
+ desc 'tag'
53
+ task :tag do
54
+ version = FakeFS::Version::VERSION
55
+ sh "git tag v#{version}"
56
+ end
57
+
58
+ desc 'Run git push'
59
+ task :push do
60
+ sh "git push origin master"
61
+ end
@@ -98,7 +98,7 @@ module FakeFS
98
98
  matches_for_pattern = lambda do |matcher|
99
99
  [FileSystem.find(matcher) || []].flatten.map do |e|
100
100
  if Dir.pwd.match(/\A\/?\z/) ||
101
- !e.to_s.match(/\A#{Dir.pwd}\/?/)
101
+ !e.to_s.match(/\A#{Dir.pwd}\/?/)
102
102
  e.to_s
103
103
  else
104
104
  e.to_s.match(/\A#{Dir.pwd}\/?/).post_match
@@ -99,11 +99,7 @@ module FakeFS
99
99
  end
100
100
 
101
101
  def self.size?(path)
102
- if exists?(path) && !size(path).zero?
103
- size(path)
104
- else
105
- nil
106
- end
102
+ size(path) if exists?(path) && !size(path).zero?
107
103
  end
108
104
 
109
105
  def self.zero?(path)
@@ -276,6 +272,14 @@ module FakeFS
276
272
  File.read(file, length, offset, mode: 'rb:ASCII-8BIT')
277
273
  end
278
274
 
275
+ def self.fnmatch?(pattern, path, flags = 0)
276
+ RealFile.fnmatch?(pattern, path, flags)
277
+ end
278
+
279
+ class << self
280
+ alias_method :fnmatch, :fnmatch?
281
+ end
282
+
279
283
  # FakeFS Stat class
280
284
  class Stat
281
285
  attr_reader :ctime, :mtime, :atime, :mode, :uid, :gid
@@ -511,6 +515,10 @@ module FakeFS
511
515
  def size
512
516
  File.size(@path)
513
517
  end
518
+
519
+ def self.realdirpath(*args)
520
+ RealFile.realdirpath(*args)
521
+ end
514
522
  end
515
523
 
516
524
  if RUBY_VERSION >= '1.9.3'
@@ -132,7 +132,7 @@ module FakeFS
132
132
  directories_under(dir).map do |d|
133
133
  d.entries.select do |f|
134
134
  (f.is_a?(FakeFile) || f.is_a?(FakeDir)) &&
135
- f.name.match(/\A(?!\.)/)
135
+ f.name.match(/\A(?!\.)/)
136
136
  end
137
137
  end.flatten.uniq
138
138
  when []
@@ -143,14 +143,14 @@ module FakeFS
143
143
  end
144
144
  else
145
145
  regex_body = pattern.gsub('.', '\.')
146
- .gsub('?', '.')
147
- .gsub('*', '.*')
148
- .gsub('(', '\(')
149
- .gsub(')', '\)')
150
- .gsub(/\{(.*?)\}/) do
151
- "(#{Regexp.last_match[1].gsub(',', '|')})"
152
- end
153
- .gsub(/\A\./, '(?!\.).')
146
+ .gsub('?', '.')
147
+ .gsub('*', '.*')
148
+ .gsub('(', '\(')
149
+ .gsub(')', '\)')
150
+ .gsub(/\{(.*?)\}/) do
151
+ "(#{Regexp.last_match[1].gsub(',', '|')})"
152
+ end
153
+ .gsub(/\A\./, '(?!\.).')
154
154
  dir.matches(/\A#{regex_body}\Z/)
155
155
  end
156
156
 
@@ -3,17 +3,17 @@ module FakeFS
3
3
  module FileUtils
4
4
  extend self
5
5
 
6
- def mkdir_p(list, _options = {})
6
+ def mkdir_p(list, options = {})
7
7
  list = [list] unless list.is_a?(Array)
8
8
  list.each do |path|
9
9
  # FileSystem.add call adds all the necessary parent directories but
10
10
  # can't set their mode. Thus, we have to collect created directories
11
11
  # here and set the mode later.
12
- if _options[:mode]
12
+ if options[:mode]
13
13
  created_dirs = []
14
14
  dir = path
15
15
 
16
- until Dir.exists?(dir)
16
+ until Dir.exist?(dir)
17
17
  created_dirs << dir
18
18
  dir = File.dirname(dir)
19
19
  end
@@ -21,10 +21,9 @@ module FakeFS
21
21
 
22
22
  FileSystem.add(path, FakeDir.new)
23
23
 
24
- if _options[:mode]
25
- created_dirs.each do |dir|
26
- File.chmod(_options[:mode], dir)
27
- end
24
+ next unless options[:mode]
25
+ created_dirs.each do |d|
26
+ File.chmod(options[:mode], d)
28
27
  end
29
28
  end
30
29
  end
@@ -38,7 +37,8 @@ module FakeFS
38
37
  parent = path.split('/')
39
38
  parent.pop
40
39
  fail Errno::ENOENT, path unless parent.join == '' ||
41
- parent.join == '.' || FileSystem.find(parent.join('/'))
40
+ parent.join == '.' ||
41
+ FileSystem.find(parent.join('/'))
42
42
  fail Errno::EEXIST, path if FileSystem.find(path)
43
43
  FileSystem.add(path, FakeDir.new)
44
44
  end
@@ -50,7 +50,7 @@ module FakeFS
50
50
  parent = l.split('/')
51
51
  parent.pop
52
52
  fail Errno::ENOENT, l unless parent.join == '' ||
53
- FileSystem.find(parent.join('/'))
53
+ FileSystem.find(parent.join('/'))
54
54
  fail Errno::ENOENT, l unless FileSystem.find(l)
55
55
  fail Errno::ENOTEMPTY, l unless FileSystem.find(l).empty?
56
56
  rm(l)
@@ -68,7 +68,7 @@ module FakeFS
68
68
  alias_method :remove, :rm
69
69
 
70
70
  def rm_rf(list, options = {})
71
- rm_r(list, options.merge(:force => true))
71
+ rm_r(list, options.merge(force: true))
72
72
  end
73
73
  alias_method :rmtree, :rm_rf
74
74
  alias_method :safe_unlink, :rm_f
@@ -201,14 +201,10 @@ module FakeFS
201
201
  uid = if user
202
202
  user.to_s.match(/[0-9]+/) ? user.to_i :
203
203
  Etc.getpwnam(user).uid
204
- else
205
- nil
206
204
  end
207
205
  gid = if group
208
206
  group.to_s.match(/[0-9]+/) ? group.to_i :
209
207
  Etc.getgrnam(group).gid
210
- else
211
- nil
212
208
  end
213
209
  File.chown(uid, gid, f)
214
210
  else
@@ -454,8 +454,8 @@ module FakeFS
454
454
  prefix1, basename1 = r1
455
455
  next if basename1 == '.'
456
456
  if basename1 == '..' ||
457
- basename_list2.empty? ||
458
- basename_list2.first != '..'
457
+ basename_list2.empty? ||
458
+ basename_list2.first != '..'
459
459
  prefix1 += basename1
460
460
  break
461
461
  end
@@ -629,33 +629,35 @@ module FakeFS
629
629
  # This method has existed since 1.8.1.
630
630
  #
631
631
  def each_line(*args, &block) # :yield: line
632
- IO.foreach(@path, *args, &block)
632
+ File.open(@path, 'r') do |io|
633
+ io.each_line(*args, &block)
634
+ end
633
635
  end
634
636
 
635
637
  # See <tt>IO.read</tt>. Returns all data from the file,
636
638
  # or the first +N+ bytes if specified.
637
639
  def read(*args)
638
- IO.read(@path, *args)
640
+ File.read(@path, *args)
639
641
  end
640
642
 
641
643
  # See <tt>IO.binread</tt>. Returns all the bytes from the file,
642
644
  # or the first +N+ if specified.
643
645
  def binread(*args)
644
- IO.binread(@path, *args)
646
+ File.binread(@path, *args)
645
647
  end
646
648
 
647
649
  # See <tt>IO.readlines</tt>. Returns all the lines from the file.
648
650
  def readlines(*args)
649
- IO.readlines(@path, *args)
651
+ File.readlines(@path, *args)
650
652
  end
651
653
 
652
- # See <tt>IO.sysopen</tt>.
653
- def sysopen(*args)
654
- IO.sysopen(@path, *args)
654
+ # See <tt>IO.sysopen</tt>. Not supported by fakefs.
655
+ def sysopen(*_args)
656
+ fail NotImplementedError, 'sysopen is not supported by fakefs'
655
657
  end
656
658
  end
657
659
 
658
- # Pathnam class
660
+ # Pathname class
659
661
  class Pathname # * File *
660
662
  # See <tt>File.atime</tt>. Returns last access time.
661
663
  def atime
@@ -1,7 +1,7 @@
1
1
  module FakeFS
2
2
  # Version module
3
3
  module Version
4
- VERSION = '0.6.1'
4
+ VERSION = '0.6.3'
5
5
 
6
6
  def self.to_s
7
7
  VERSION
@@ -97,16 +97,16 @@ class FakeFileTest < Test::Unit::TestCase
97
97
  end
98
98
 
99
99
  def test_file_size_question_works
100
- assert_nil FileTest.size?("does-not-exist.txt")
100
+ assert_nil FileTest.size?('does-not-exist.txt')
101
101
 
102
- File.open("empty.txt", 'w') do |f|
102
+ File.open('empty.txt', 'w') do |f|
103
103
  f << ''
104
104
  end
105
- assert_nil FileTest.size?("empty.txt")
105
+ assert_nil FileTest.size?('empty.txt')
106
106
 
107
- File.open("one-char.txt", 'w') do |f|
107
+ File.open('one-char.txt', 'w') do |f|
108
108
  f << 'a'
109
109
  end
110
- assert_equal 1, FileTest.size?("one-char.txt")
110
+ assert_equal 1, FileTest.size?('one-char.txt')
111
111
  end
112
112
  end
@@ -119,7 +119,7 @@ class FakeFSTest < Test::Unit::TestCase
119
119
 
120
120
  def test_unlink_doesnt_error_on_file_not_found_with_rm_rf
121
121
  assert_nothing_raised do
122
- FileUtils.rm_rf("/foo")
122
+ FileUtils.rm_rf('/foo')
123
123
  end
124
124
  end
125
125
 
@@ -2424,18 +2424,6 @@ class FakeFSTest < Test::Unit::TestCase
2424
2424
  assert FileTest.writable?('dir'), 'directories are writable'
2425
2425
  end
2426
2426
 
2427
- def test_pathname_exists_returns_correct_value
2428
- FileUtils.touch 'foo'
2429
- assert Pathname.new('foo').exist?
2430
-
2431
- assert !Pathname.new('bar').exist?
2432
- end
2433
-
2434
- def test_pathname_method_is_faked
2435
- FileUtils.mkdir_p '/path'
2436
- assert Pathname('/path').exist?, 'Pathname() method is faked'
2437
- end
2438
-
2439
2427
  def test_dir_mktmpdir
2440
2428
  FileUtils.mkdir '/tmp'
2441
2429
 
@@ -2620,6 +2608,12 @@ class FakeFSTest < Test::Unit::TestCase
2620
2608
  end
2621
2609
  end
2622
2610
 
2611
+ def test_fnmatch
2612
+ assert_equal File.fnmatch?('test', 'test'), true
2613
+ assert_equal File.fnmatch('nope', 'blargh'), false
2614
+ assert_equal File.fnmatch?('nope', 'blargh'), File.fnmatch('nope', 'blargh')
2615
+ end
2616
+
2623
2617
  if RUBY_VERSION >= '1.9.1'
2624
2618
  def test_absolute_path_with_absolute_path
2625
2619
  assert_equal '/foo/bar', File.absolute_path('/foo/bar')
@@ -147,4 +147,12 @@ class FileStatTest < Test::Unit::TestCase
147
147
  assert !File.respond_to?(:realpath)
148
148
  end
149
149
  end
150
+
151
+ def test_responds_to_realdirpath_only_on_1_9_2_and_greater
152
+ if RUBY_VERSION >= '1.9.2'
153
+ assert File.respond_to?(:realdirpath)
154
+ else
155
+ assert !File.respond_to?(:realdirpath)
156
+ end
157
+ end
150
158
  end
@@ -0,0 +1,73 @@
1
+ require 'test_helper'
2
+
3
+ # Fake Pathname test class
4
+ class FakePathnameTest < Test::Unit::TestCase
5
+ include FakeFS
6
+
7
+ def setup
8
+ FakeFS.activate!
9
+ FileSystem.clear
10
+
11
+ @path = 'foo'
12
+ @pathname = Pathname.new(@path)
13
+ end
14
+
15
+ def teardown
16
+ FakeFS.deactivate!
17
+ end
18
+
19
+ def test_filetest_exists_returns_correct_value
20
+ assert !@pathname.exist?
21
+
22
+ File.write(@path, '')
23
+
24
+ assert @pathname.exist?
25
+ end
26
+
27
+ def test_io_each_line_with_block_yields_lines
28
+ File.write(@path, "one\ntwo\nthree\n")
29
+
30
+ yielded = []
31
+ @pathname.each_line { |line| yielded << line }
32
+
33
+ assert_equal yielded, ["one\n", "two\n", "three\n"]
34
+ end
35
+
36
+ def test_io_each_line_without_block_returns_enumerator
37
+ File.write(@path, '')
38
+
39
+ assert @pathname.each_line.is_a?(Enumerator)
40
+ end
41
+
42
+ def test_io_read_returns_file_contents
43
+ File.write(@path, "some\ncontent")
44
+
45
+ assert_equal @pathname.read, "some\ncontent"
46
+ assert_equal @pathname.read(6), "some\nc"
47
+ assert_equal @pathname.read(4, 3), "e\nco"
48
+ end
49
+
50
+ def test_io_binread_returns_file_contents
51
+ File.write(@path, "some\ncontent")
52
+
53
+ assert_equal @pathname.binread, "some\ncontent"
54
+ assert_equal @pathname.binread(6), "some\nc"
55
+ assert_equal @pathname.binread(4, 3), "e\nco"
56
+ end
57
+
58
+ def test_io_binread_reads_contents_as_binary
59
+ File.write(@path, "some\ncontent")
60
+
61
+ assert_equal @pathname.binread.encoding.name, 'ASCII-8BIT'
62
+ end
63
+
64
+ def test_io_readlines_returns_array_of_lines
65
+ File.write(@path, "one\ntwo\nthree\n")
66
+
67
+ assert_equal @pathname.readlines, ["one\n", "two\n", "three\n"]
68
+ end
69
+
70
+ def test_io_sysopen_is_unsupported
71
+ assert_raise(NotImplementedError) { @pathname.sysopen }
72
+ end
73
+ 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.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-01-13 00:00:00.000000000 Z
15
+ date: 2015-01-14 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -119,6 +119,7 @@ files:
119
119
  - test/fakefs_test.rb
120
120
  - test/file/stat_test.rb
121
121
  - test/kernel_test.rb
122
+ - test/pathname_test.rb
122
123
  - test/safe_test.rb
123
124
  - test/test_helper.rb
124
125
  - test/verify.rb
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
143
  version: '0'
143
144
  requirements: []
144
145
  rubyforge_project:
145
- rubygems_version: 2.4.2
146
+ rubygems_version: 2.4.5
146
147
  signing_key:
147
148
  specification_version: 4
148
149
  summary: A fake filesystem. Use it in your tests.
@@ -162,6 +163,7 @@ test_files:
162
163
  - test/fakefs_test.rb
163
164
  - test/file/stat_test.rb
164
165
  - test/kernel_test.rb
166
+ - test/pathname_test.rb
165
167
  - test/safe_test.rb
166
168
  - test/test_helper.rb
167
169
  - test/verify.rb