Sha256: 189c864b86001fd047e1a129bd8a321a7edd6e65d58f4c04816d97a5263baef9
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
require 'test_helper' # FakeFS safe test class class FakeFSSafeTest < Minitest::Test def setup FakeFS.deactivate! end def teardown FakeFS.activate! end def test_FakeFS_activated_is_accurate 2.times do FakeFS.deactivate! refute FakeFS.activated? FakeFS.activate! assert FakeFS.activated? end end def test_FakeFS_method_does_not_intrude_on_global_namespace path = 'file.txt' FakeFS do File.open(path, 'w') { |f| f.write 'Yatta!' } assert File.exist?(path) end refute File.exist?(path) end def test_FakeFS_method_returns_value_of_yield result = FakeFS do File.open('myfile.txt', 'w') { |f| f.write 'Yatta!' } File.read('myfile.txt') end assert_equal result, 'Yatta!' end def test_FakeFS_method_does_not_deactivate_FakeFS_if_already_activated FakeFS.activate! FakeFS {} assert FakeFS.activated? end def test_FakeFS_method_can_be_nested FakeFS do assert FakeFS.activated? FakeFS do assert FakeFS.activated? end assert FakeFS.activated? end refute FakeFS.activated? end def test_FakeFS_method_can_be_nested_with_FakeFS_without FakeFS do assert FakeFS.activated? FakeFS.without do refute FakeFS.activated? end assert FakeFS.activated? end refute FakeFS.activated? end def test_FakeFS_method_deactivates_FakeFS_when_block_raises_exception begin FakeFS do fail 'boom!' end rescue 'Nothing to do' end refute FakeFS.activated? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fakefs-0.7.0 | test/safe_test.rb |
fakefs-0.6.7 | test/safe_test.rb |