From 2e55319dc0c2f87af8f28c56ce6096060d22c111 Mon Sep 17 00:00:00 2001 From: Noah Paessel Date: Tue, 18 Jan 2011 20:22:26 -0500 Subject: [PATCH] add file#split. Closes #61 --- lib/fakefs/file.rb | 4 ++++ test/fakefs_test.rb | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index 15965fe..01931c6 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -215,6 +215,10 @@ module FakeFS File::Stat.new(file, true) end + def self.split(path) + return RealFile.split(path) + end + class Stat attr_reader :ctime, :mtime diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 211471c..fa7527d 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -3,6 +3,14 @@ require "test_helper" class FakeFSTest < Test::Unit::TestCase include FakeFS + def test_split + assert File.respond_to? :split + filename = "/this/is/what/we/expect.txt" + path,filename = File.split(filename) + assert_equal path, "/this/is/what/we" + assert_equal filename, "expect.txt" + end + def setup FakeFS.activate! FileSystem.clear