Sha256: 13a50fe435e08f4b87af747168d45eaab34ef8739069d448a509f3d3ab71ece5

Contents?: true

Size: 649 Bytes

Versions: 2

Compression:

Stored size: 649 Bytes

Contents

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'fakefs/safe'
require 'test/unit'

class FakeFSSafeTest < Test::Unit::TestCase
  def setup
    FakeFS.deactivate!
  end

  def test_FakeFS_method_does_not_intrude_on_global_namespace
    path = '/path/to/file.txt'

    FakeFS do
      File.open(path, 'w') { |f| f.write "Yatta!" }
      assert File.exists?(path)
    end

    assert ! File.exists?(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
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
bmabey-fakefs-0.1.1.1 test/safe_test.rb
fakefs-0.2.0 test/safe_test.rb