fakefs 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org/'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,62 +0,0 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'test')
3
-
4
- require 'bundler/setup'
5
- require 'rake/testtask'
6
- require File.expand_path(File.join(File.dirname(__FILE__), "lib", "fakefs", "version"))
7
-
8
- Rake::TestTask.new do |t|
9
- t.libs << 'test'
10
- t.test_files = FileList['test/**/*test.rb']
11
- t.verbose = true
12
- end
13
-
14
- begin
15
- require 'rspec/core/rake_task'
16
- desc 'Run specs'
17
- RSpec::Core::RakeTask.new
18
- rescue LoadError
19
- puts "Spec task can't be loaded. `gem install rspec`"
20
- end
21
-
22
- begin
23
- require 'rubocop/rake_task'
24
- desc 'Run RuboCop'
25
- RuboCop::RakeTask.new(:rubocop)
26
- rescue LoadError
27
- puts "Rubocop task can't be loaded. `gem install rubocop`"
28
- end
29
-
30
- task default: [:test, :spec, :rubocop]
31
-
32
- desc 'Push a new version to rubygems.org'
33
- task :publish => [:rubocop, :test, :spec, :rubocop, :update_contributors, :tag, :release, :push]
34
-
35
- desc 'Update contributors'
36
- task :update_contributors do
37
- git_rank_contributors = "#{File.dirname(File.expand_path(__FILE__))}/etc/git-rank-contributors"
38
-
39
- sh "#{git_rank_contributors} > CONTRIBUTORS"
40
- if `git status | grep CONTRIBUTORS`.strip.length > 0
41
- sh "git add CONTRIBUTORS"
42
- sh "git commit -m 'Update contributors for release'"
43
- end
44
- end
45
-
46
- desc 'Release a new version'
47
- task :release do
48
- sh "gem build fakefs.gemspec"
49
- sh "gem push fakefs-*.gem"
50
- end
51
-
52
- desc 'tag'
53
- task :tag do
54
- version = FakeFS::Version::VERSION
55
- sh "git tag v#{version}"
56
- sh "git push --tags"
57
- end
58
-
59
- desc 'Run git push'
60
- task :push do
61
- sh "git push origin master"
62
- end
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ## git-rank-contributors: a simple script to trace through the logs and
4
- ## rank contributors by the total size of the diffs they're responsible for.
5
- ## A change counts twice as much as a plain addition or deletion.
6
- ##
7
- ## Output may or may not be suitable for inclusion in a CREDITS file.
8
- ## Probably not without some editing, because people often commit from more
9
- ## than one address.
10
- ##
11
- ## git-rank-contributors Copyright 2008 William Morgan <wmorgan-git-wt-add@masanjin.net>.
12
- ## This program is free software: you can redistribute it and/or modify
13
- ## it under the terms of the GNU General Public License as published by
14
- ## the Free Software Foundation, either version 3 of the License, or (at
15
- ## your option) any later version.
16
- ##
17
- ## This program is distributed in the hope that it will be useful,
18
- ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- ## GNU General Public License for more details.
21
- ##
22
- ## You can find the GNU General Public License at:
23
- ## http://www.gnu.org/licenses/
24
-
25
- class String
26
- def obfuscate; gsub(/@/, " at the ").gsub(/\.(\w+)(>|$)/, ' dot \1s\2') end
27
- end
28
-
29
- lines = {}
30
- verbose = ARGV.delete("-v")
31
- obfuscate = ARGV.delete("-o")
32
-
33
- author = nil
34
- state = :pre_author
35
- `git log -p --no-color`.lines.each do |l|
36
- case
37
- when (state == :pre_author || state == :post_author) && l =~ /Author: (.*)$/
38
- author = $1
39
- state = :post_author
40
- lines[author] ||= 0
41
- when state == :post_author && l =~ /^\+\+\+/
42
- state = :in_diff
43
- when state == :in_diff && l =~ /^[\+\-]/
44
- lines[author] += 1
45
- when state == :in_diff && l =~ /^commit /
46
- state = :pre_author
47
- end
48
- end
49
-
50
- lines.sort_by { |a, c| -c }.each do |a, c|
51
- a = a.obfuscate if obfuscate
52
- if verbose
53
- puts "#{a}: #{c} lines of diff"
54
- else
55
- puts a
56
- end
57
- end
data/fakefs.gemspec DELETED
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'fakefs/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "fakefs"
8
- spec.version = FakeFS::Version.to_s
9
- spec.authors = ["Chris Wanstrath", "Scott Taylor", "Jeff Hodges", "Pat Nakajima", "Brian Donovan"]
10
- spec.email = ["chris@ozmm.org"]
11
- spec.description = %q{A fake filesystem. Use it in your tests.}
12
- spec.summary = %q{A fake filesystem. Use it in your tests.}
13
- spec.homepage = "http://github.com/defunkt/fakefs"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake", "~> 10.3"
23
- spec.add_development_dependency "rspec", "~> 3.1"
24
- spec.add_development_dependency 'rubocop', '~> 0.35.0'
25
- spec.add_development_dependency 'minitest', '~> 5.5'
26
- spec.add_development_dependency 'minitest-rg', '~> 5.1'
27
- end
@@ -1,18 +0,0 @@
1
- require 'find'
2
- require 'fakefs/spec_helpers'
3
-
4
- RSpec.configure do |c|
5
- c.mock_with(:rspec)
6
- c.include(FakeFS::SpecHelpers, fakefs: true)
7
- c.disable_monkey_patching!
8
- end
9
-
10
- if RUBY_VERSION >= '2.1'
11
- RSpec.describe 'Find.find', fakefs: true do
12
- it 'does not give an ArgumentError' do
13
- FileUtils.mkdir_p('/tmp/foo')
14
- found = Find.find('/tmp').to_a
15
- expect(found).to eq(%w(/tmp /tmp/foo))
16
- end
17
- end
18
- end
@@ -1,102 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # FakeFs module for tests
4
- module FakeFS
5
- RSpec.describe SpecHelpers do
6
- before do
7
- @rspec_example_group = Class.new do
8
- def self.before(_sym = :each)
9
- yield if block_given?
10
- end
11
-
12
- def self.after(_sym = :each)
13
- yield if block_given?
14
- end
15
- end
16
- end
17
-
18
- describe 'when extending' do
19
- context 'before each' do
20
- it 'should call it' do
21
- expect(@rspec_example_group).to receive(:before).with(:each)
22
- @rspec_example_group.extend FakeFS::SpecHelpers
23
- end
24
-
25
- it 'should call FakeFS.activate!' do
26
- expect(FakeFS).to receive(:activate!)
27
- @rspec_example_group.extend FakeFS::SpecHelpers
28
- end
29
- end
30
-
31
- context 'after each' do
32
- it 'should call it' do
33
- expect(@rspec_example_group).to receive(:after).with(:each)
34
- @rspec_example_group.extend FakeFS::SpecHelpers
35
- end
36
-
37
- it 'should deactivate fakefs' do
38
- expect(FakeFS).to receive(:deactivate!)
39
- @rspec_example_group.extend FakeFS::SpecHelpers
40
- end
41
-
42
- it 'should clear the fakefs filesystem for the next run' do
43
- expect(FakeFS::FileSystem).to receive(:clear)
44
- @rspec_example_group.extend FakeFS::SpecHelpers
45
- end
46
- end
47
- end
48
-
49
- describe 'when including' do
50
- it 'should call before :each' do
51
- expect(@rspec_example_group).to receive(:before)
52
- @rspec_example_group.class_eval do
53
- include FakeFS::SpecHelpers
54
- end
55
- end
56
- end
57
-
58
- describe SpecHelpers::All do
59
- describe 'when extending' do
60
- context 'before :all' do
61
- it 'should call it' do
62
- expect(@rspec_example_group).to receive(:before).with(:all)
63
- @rspec_example_group.extend FakeFS::SpecHelpers::All
64
- end
65
-
66
- it 'should call FakeFS.activate!' do
67
- expect(FakeFS).to receive(:activate!)
68
- @rspec_example_group.extend FakeFS::SpecHelpers::All
69
- end
70
- end
71
-
72
- context 'after :all' do
73
- it 'should call it' do
74
- expect(@rspec_example_group).to receive(:after).with(:all)
75
- @rspec_example_group.extend FakeFS::SpecHelpers::All
76
- end
77
-
78
- it 'should call FakeFS.deactivate!' do
79
- expect(FakeFS).to receive(:deactivate!)
80
- @rspec_example_group.extend FakeFS::SpecHelpers::All
81
- end
82
-
83
- it 'should not call FakeFS::FileSystem.clear' do
84
- expect(FakeFS::FileSystem).to_not receive(:clear)
85
- @rspec_example_group.extend FakeFS::SpecHelpers::All
86
- end
87
- end
88
- end
89
-
90
- describe 'when including' do
91
- context 'before :all' do
92
- it 'should call it' do
93
- expect(@rspec_example_group).to receive(:before)
94
- @rspec_example_group.class_eval do
95
- include FakeFS::SpecHelpers::All
96
- end
97
- end
98
- end
99
- end
100
- end
101
- end
102
- end
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color
data/spec/spec_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
-
3
- require 'fakefs/spec_helpers'
@@ -1,21 +0,0 @@
1
- require 'test_helper'
2
- require 'tempfile'
3
-
4
- # Tempfile test class
5
- class TempfileTest < Minitest::Test
6
- include FakeFS
7
-
8
- if RUBY_VERSION >= '2.1'
9
- def test_should_not_raise_error
10
- FakeFS do
11
- # nothing raised
12
- FileUtils.mkdir_p('/tmp')
13
- Tempfile.open('test')
14
- end
15
- end
16
- else
17
- def test_noop
18
- # TODO: Remove me when we add non-2.1 tests.
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- # File join test class
4
- class FileJoin < Minitest::Test
5
- def setup
6
- FakeFS.activate!
7
- end
8
-
9
- def teardown
10
- FakeFS.deactivate!
11
- end
12
-
13
- [
14
- %w(a b), %w(a/ b), %w(a /b), %w(a/ /b), %w(a / b)
15
- ].each_with_index do |args, i|
16
- define_method "test_file_join_#{i}" do
17
- assert_equal RealFile.join(args), File.join(args)
18
- end
19
- end
20
- end
@@ -1,60 +0,0 @@
1
- require 'test_helper'
2
-
3
- # File stat test class
4
- class FileStat < Minitest::Test
5
- def setup
6
- FakeFS.activate!
7
- FakeFS::FileSystem.clear
8
- end
9
-
10
- def teardown
11
- FakeFS.deactivate!
12
- end
13
-
14
- def test_calling_lstat_should_create_a_new_file_stat_object
15
- File.open('foo', 'w') do |f|
16
- f << 'bar'
17
- end
18
-
19
- File.open('foo') do |f|
20
- assert_equal File::Stat, f.lstat.class
21
- end
22
- end
23
-
24
- def test_lstat_should_use_correct_file
25
- File.open('bar', 'w') do |f|
26
- f << '1'
27
- end
28
-
29
- File.open('bar') do |f|
30
- assert_equal 1, f.lstat.size
31
- end
32
- end
33
-
34
- def test_lstat_should_report_on_symlink_itself
35
- File.open('foo', 'w') { |f| f << 'some content' }
36
- File.symlink 'foo', 'my_symlink'
37
-
38
- refute_equal File.lstat('my_symlink').size, File.lstat('foo').size
39
- end
40
-
41
- def test_should_report_on_symlink_itself_with_size_instance_method
42
- File.open('foo', 'w') { |f| f << 'some content' }
43
- File.symlink 'foo', 'my_symlink'
44
-
45
- file = File.open('foo')
46
- symlink = File.open('my_symlink')
47
-
48
- refute_equal file.lstat.size, symlink.lstat.size
49
- end
50
-
51
- def test_symlink_size_is_size_of_path_pointed_to
52
- File.open('a', 'w') { |x| x << 'foobarbazfoobarbaz' }
53
- File.symlink 'a', 'one_char_symlink'
54
- assert_equal 1, File.lstat('one_char_symlink').size
55
-
56
- File.open('ab', 'w') { |x| x << 'foobarbazfoobarbaz' }
57
- File.symlink 'ab', 'two_char_symlink'
58
- assert_equal 2, File.lstat('two_char_symlink').size
59
- end
60
- end
@@ -1,40 +0,0 @@
1
- require 'test_helper'
2
-
3
- # File stat test class
4
- class FileStat < Minitest::Test
5
- def setup
6
- FakeFS.activate!
7
- FakeFS::FileSystem.clear
8
- end
9
-
10
- def teardown
11
- FakeFS.deactivate!
12
- end
13
-
14
- def test_calling_stat_should_create_a_new_file_stat_object
15
- File.open('foo', 'w') do |f|
16
- f << 'bar'
17
- end
18
-
19
- File.open('foo') do |f|
20
- assert_equal File::Stat, f.stat.class
21
- end
22
- end
23
-
24
- def test_stat_should_use_correct_file
25
- File.open('bar', 'w') do |f|
26
- f << '1'
27
- end
28
-
29
- File.open('bar') do |f|
30
- assert_equal 1, f.stat.size
31
- end
32
- end
33
-
34
- def test_stat_should_report_on_symlink_pointer
35
- File.open('foo', 'w') { |f| f << 'some content' }
36
- File.symlink 'foo', 'my_symlink'
37
-
38
- assert_equal File.stat('my_symlink').size, File.stat('foo').size
39
- end
40
- end
@@ -1,45 +0,0 @@
1
- require 'test_helper'
2
-
3
- # File SysSeek test class
4
- class FileSysSeek < Minitest::Test
5
- def setup
6
- FakeFS.activate!
7
- FakeFS::FileSystem.clear
8
- end
9
-
10
- def teardown
11
- FakeFS.deactivate!
12
- end
13
-
14
- def test_should_seek_to_position
15
- File.open('foo', 'w') do |f|
16
- f << '0123456789'
17
- end
18
-
19
- File.open('foo', 'r') do |f|
20
- f.sysseek(3)
21
- assert_equal 3, f.pos
22
-
23
- f.sysseek(0)
24
- assert_equal 0, f.pos
25
- end
26
- end
27
-
28
- def test_seek_returns_offset_into_file
29
- File.open('foo', 'w') do |f|
30
- # 66 chars long
31
- str = '0123456789' \
32
- '0123456789' \
33
- '0123456789' \
34
- '0123456789' \
35
- '0123456789' \
36
- '0123456789' \
37
- '012345'
38
-
39
- f << str
40
- end
41
-
42
- f = File.open('foo')
43
- assert_equal 53, f.sysseek(-13, IO::SEEK_END)
44
- end
45
- end