Sha256: fa7e589706552bca3a82b99775fbee2b2103ecc6849c19003c33096a5e67cb8f

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'test_helper'

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

  def teardown
    FakeFS.activate!
  end

  def test_can_exec_normally
    out = open("|echo 'foo'")
    assert_equal "foo\n", out.gets
  end

  def test_fake_kernel_can_create_subprocesses
    FakeFS do
      out = open("|echo 'foo'")
      assert_equal "foo\n", out.gets
    end
  end

  def test_fake_kernel_can_create_new_file
    FakeFS do
      FileUtils.mkdir_p '/path/to/'
      open('/path/to/file', "w") do |f|
        f << "test"
      end
      assert_kind_of FakeFile, FileSystem.fs['path']['to']['file']
    end
  end

  def test_fake_kernel_can_do_stuff
    FakeFS do
      FileUtils.mkdir_p('/tmp')
      File.open('/tmp/a', 'w+') { |f| f.puts 'test' }

      begin
      puts open('/tmp/a').read
      rescue Exception => e
        puts e
        puts e.backtrace
        raise e
      end
    end
  end

  def test_can_exec_normally2
    out = open("|echo 'foo'")
    assert_equal "foo\n", out.gets
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fakefs-0.5.4 test/kernel_test.rb
fakefs-0.5.3 test/kernel_test.rb