Cleanup trailing whitespace
This commit is contained in:
parent
d2264eb646
commit
2877f7d4c1
@ -37,11 +37,11 @@ Don't Fake the FS Immediately
|
|||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
require 'fakefs/safe'
|
require 'fakefs/safe'
|
||||||
|
|
||||||
FakeFS.activate!
|
FakeFS.activate!
|
||||||
# your code
|
# your code
|
||||||
FakeFS.deactivate!
|
FakeFS.deactivate!
|
||||||
|
|
||||||
# or
|
# or
|
||||||
FakeFS do
|
FakeFS do
|
||||||
# your code
|
# your code
|
||||||
|
@ -24,7 +24,7 @@ module FakeFS
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def method_missing(*args, &block)
|
def method_missing(*args, &block)
|
||||||
entry.send(*args, &block)
|
entry.send(*args, &block)
|
||||||
end
|
end
|
||||||
|
@ -36,7 +36,7 @@ module FakeFS
|
|||||||
ln_s(target, path, { :force => true })
|
ln_s(target, path, { :force => true })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def cp(src, dest)
|
def cp(src, dest)
|
||||||
dst_file = FileSystem.find(dest)
|
dst_file = FileSystem.find(dest)
|
||||||
|
@ -54,4 +54,4 @@ module FakeFS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1 +1 @@
|
|||||||
--color
|
--color
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
||||||
|
|
||||||
require 'fakefs/spec_helpers'
|
require 'fakefs/spec_helpers'
|
||||||
|
@ -7,7 +7,7 @@ class FakeFileTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
FileSystem.clear
|
FileSystem.clear
|
||||||
|
|
||||||
@file = FakeFile.new
|
@file = FakeFile.new
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -43,9 +43,9 @@ class FakeFileTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_links_are_mutual
|
def test_links_are_mutual
|
||||||
other_file = FakeFile.new
|
other_file = FakeFile.new
|
||||||
|
|
||||||
@file.link(other_file)
|
@file.link(other_file)
|
||||||
|
|
||||||
assert_equal [@file, other_file], other_file.links
|
assert_equal [@file, other_file], other_file.links
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class FakeFSTest < Test::Unit::TestCase
|
|||||||
FileUtils.mkdir_p("/path/to/dir")
|
FileUtils.mkdir_p("/path/to/dir")
|
||||||
assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir']
|
assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir']
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_can_create_directories_with_mkpath
|
def test_can_create_directories_with_mkpath
|
||||||
FileUtils.mkpath("/path/to/dir")
|
FileUtils.mkpath("/path/to/dir")
|
||||||
assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir']
|
assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir']
|
||||||
@ -74,14 +74,14 @@ class FakeFSTest < Test::Unit::TestCase
|
|||||||
FileUtils.ln_s(target, '/path/to/link')
|
FileUtils.ln_s(target, '/path/to/link')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_can_force_creation_of_symlinks
|
def test_can_force_creation_of_symlinks
|
||||||
FileUtils.mkdir_p(target = "/path/to/first/target")
|
FileUtils.mkdir_p(target = "/path/to/first/target")
|
||||||
FileUtils.ln_s(target, "/path/to/link")
|
FileUtils.ln_s(target, "/path/to/link")
|
||||||
assert_kind_of FakeSymlink, FileSystem.fs['path']['to']['link']
|
assert_kind_of FakeSymlink, FileSystem.fs['path']['to']['link']
|
||||||
FileUtils.ln_s(target, '/path/to/link', :force => true)
|
FileUtils.ln_s(target, '/path/to/link', :force => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_symlink_using_ln_sf
|
def test_create_symlink_using_ln_sf
|
||||||
FileUtils.mkdir_p(target = "/path/to/first/target")
|
FileUtils.mkdir_p(target = "/path/to/first/target")
|
||||||
FileUtils.ln_s(target, "/path/to/link")
|
FileUtils.ln_s(target, "/path/to/link")
|
||||||
@ -1126,38 +1126,38 @@ class FakeFSTest < Test::Unit::TestCase
|
|||||||
def test_tmpdir
|
def test_tmpdir
|
||||||
assert Dir.tmpdir == "/tmp"
|
assert Dir.tmpdir == "/tmp"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hard_link_creates_file
|
def test_hard_link_creates_file
|
||||||
FileUtils.touch("/foo")
|
FileUtils.touch("/foo")
|
||||||
|
|
||||||
File.link("/foo", "/bar")
|
File.link("/foo", "/bar")
|
||||||
assert File.exists?("/bar")
|
assert File.exists?("/bar")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hard_link_with_missing_file_raises_error
|
def test_hard_link_with_missing_file_raises_error
|
||||||
assert_raises(Errno::ENOENT) do
|
assert_raises(Errno::ENOENT) do
|
||||||
File.link("/foo", "/bar")
|
File.link("/foo", "/bar")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hard_link_with_existing_destination_file
|
def test_hard_link_with_existing_destination_file
|
||||||
FileUtils.touch("/foo")
|
FileUtils.touch("/foo")
|
||||||
FileUtils.touch("/bar")
|
FileUtils.touch("/bar")
|
||||||
|
|
||||||
assert_raises(Errno::EEXIST) do
|
assert_raises(Errno::EEXIST) do
|
||||||
File.link("/foo", "/bar")
|
File.link("/foo", "/bar")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hard_link_returns_0_when_successful
|
def test_hard_link_returns_0_when_successful
|
||||||
FileUtils.touch("/foo")
|
FileUtils.touch("/foo")
|
||||||
|
|
||||||
assert_equal 0, File.link("/foo", "/bar")
|
assert_equal 0, File.link("/foo", "/bar")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hard_link_returns_duplicate_file
|
def test_hard_link_returns_duplicate_file
|
||||||
File.open("/foo", "w") { |x| x << "some content" }
|
File.open("/foo", "w") { |x| x << "some content" }
|
||||||
|
|
||||||
File.link("/foo", "/bar")
|
File.link("/foo", "/bar")
|
||||||
assert_equal "some content", File.read("/bar")
|
assert_equal "some content", File.read("/bar")
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ class FakeFSSafeTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal result, "Yatta!"
|
assert_equal result, "Yatta!"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_FakeFS_method_deactivates_FakeFS_when_block_raises_exception
|
def test_FakeFS_method_deactivates_FakeFS_when_block_raises_exception
|
||||||
begin
|
begin
|
||||||
FakeFS do
|
FakeFS do
|
||||||
@ -34,9 +34,9 @@ class FakeFSSafeTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal RealFile, File, "File is #{File} (should be #{RealFile})"
|
assert_equal RealFile, File, "File is #{File} (should be #{RealFile})"
|
||||||
assert_equal RealFileUtils, FileUtils, "FileUtils is #{FileUtils} (should be #{RealFileUtils})"
|
assert_equal RealFileUtils, FileUtils, "FileUtils is #{FileUtils} (should be #{RealFileUtils})"
|
||||||
assert_equal RealDir, Dir, "Dir is #{Dir} (should be #{RealDir})"
|
assert_equal RealDir, Dir, "Dir is #{Dir} (should be #{RealDir})"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,20 +5,20 @@
|
|||||||
# $ ruby test/verify.rb | grep "not implemented"
|
# $ ruby test/verify.rb | grep "not implemented"
|
||||||
require 'fakefs'
|
require 'fakefs'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
class FakeFSVerifierTest < Test::Unit::TestCase
|
class FakeFSVerifierTest < Test::Unit::TestCase
|
||||||
(RealFile.methods - Class.new.methods).each do |name|
|
(RealFile.methods - Class.new.methods).each do |name|
|
||||||
define_method("test #{name} class method") do
|
define_method("test #{name} class method") do
|
||||||
assert File.respond_to?(name), "File.#{name} not implemented"
|
assert File.respond_to?(name), "File.#{name} not implemented"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
(RealFile.instance_methods - Enumerable.instance_methods).each do |name|
|
(RealFile.instance_methods - Enumerable.instance_methods).each do |name|
|
||||||
define_method("test #{name} instance method") do
|
define_method("test #{name} instance method") do
|
||||||
assert File.instance_methods.include?(name), "File##{name} not implemented"
|
assert File.instance_methods.include?(name), "File##{name} not implemented"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
(RealFileUtils.methods - Class.new.methods).each do |name|
|
(RealFileUtils.methods - Class.new.methods).each do |name|
|
||||||
define_method("test #{name} module method") do
|
define_method("test #{name} module method") do
|
||||||
assert FileUtils.respond_to?(name), "FileUtils.#{name} not implemented"
|
assert FileUtils.respond_to?(name), "FileUtils.#{name} not implemented"
|
||||||
|
Loading…
Reference in New Issue
Block a user