Skip to content

Instantly share code, notes, and snippets.

@blowmage
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blowmage/9262760 to your computer and use it in GitHub Desktop.
Save blowmage/9262760 to your computer and use it in GitHub Desktop.
Test to reproduce the problems we were having with FakeFS in the minitest-rails tests. Use version 0.5.0 of FakeFS, and whatever the current version of Thor is.
require "minitest/autorun"
require "thor"
require "fakefs/safe"
class SampleGenerator < Thor::Group
include Thor::Actions
def start *args
template "foo.erb", "new/path/here/foo.rb"
end
end
class TestFakeFSThor < Minitest::Test
def setup
@dir = Dir.pwd
`touch foo.erb`
end
def test_thor
SampleGenerator.source_root @dir
out, err = capture_io do
SampleGenerator.new.start "thor"
end
assert_match /new\/path\/here\/foo.rb/, out
end
def test_thor_with_fakefs
FakeFS.activate!
# Uncommenting the following will make it pass
#FakeFS::FileSystem.dir_levels.delete "/"
FakeFS::FileSystem.clone @dir
test_thor
ensure
FakeFS::FileSystem.clear
FakeFS.deactivate!
end
end
@blowmage
Copy link
Author

Hat tip to @zenspider for isolating the issue to "/" being in the dir_levels array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment