Skip to content

Commit

Permalink
Substitute Pathname to get tests to pass in ruby 1.9.3
Browse files Browse the repository at this point in the history
Moved pathname.rb from ruby 1.9.2 into project in order to continue compatibility to 1.9.3 where
the functionality has been moved into c. In the c version of the file, the unset_const trick
doesn't work because the constant rb_cFile in the c file is never modified. I think this is
actually a bug in how ruby MRI operates, but the fix is a little bit complicated.
  • Loading branch information
lukaso authored and jfirebaugh committed Apr 17, 2012
1 parent 332735b commit dc0d08d
Show file tree
Hide file tree
Showing 4 changed files with 873 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fakefs.gemspec
Expand Up @@ -5,7 +5,7 @@

Gem::Specification.new do |s|
s.name = %q{fakefs}
s.version = "0.4.0"
s.version = "0.4.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Chris Wanstrath", "Scott Taylor", "Jeff Hodges", "Pat Nakajima"]
Expand Down
6 changes: 6 additions & 0 deletions lib/fakefs/base.rb
Expand Up @@ -2,6 +2,7 @@
RealFileTest = FileTest
RealFileUtils = FileUtils
RealDir = Dir
RealPathname = Pathname

module FakeFS
def self.activate!
Expand All @@ -10,11 +11,14 @@ def self.activate!
remove_const(:File)
remove_const(:FileTest)
remove_const(:FileUtils)
remove_const(:Pathname) if RUBY_VERSION >= "1.9.3"


const_set(:Dir, FakeFS::Dir)
const_set(:File, FakeFS::File)
const_set(:FileUtils, FakeFS::FileUtils)
const_set(:FileTest, FakeFS::FileTest)
const_set(:Pathname, FakeFS::Pathname) if RUBY_VERSION >= "1.9.3"
end
true
end
Expand All @@ -25,11 +29,13 @@ def self.deactivate!
remove_const(:File)
remove_const(:FileTest)
remove_const(:FileUtils)
remove_const(:Pathname) if RUBY_VERSION >= "1.9.3"

const_set(:Dir, RealDir)
const_set(:File, RealFile)
const_set(:FileTest, RealFileTest)
const_set(:FileUtils, RealFileUtils)
const_set(:Pathname, RealPathname) if RUBY_VERSION >= "1.9.3"
end
true
end
Expand Down

0 comments on commit dc0d08d

Please sign in to comment.