Last active
August 29, 2015 13:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hat tip to @zenspider for isolating the issue to "/" being in the
dir_levels
array.