Sha256: 3f34cc149f9d5049cd23b0f81f50efee7e81f5443fa59fb94ad3253b065f6fe0

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

require File.join(File.dirname(__FILE__), 'helper')

class TestRunner < Test::Unit::TestCase
  context "a test runner" do
    setup do
      @pipe = Hydra::Pipe.new
      @child = Process.fork do
        @pipe.identify_as_child
        Hydra::Runner.new(@pipe)
      end
      @pipe.identify_as_parent
    end
    teardown do
      @pipe.close
      Process.wait(@child)
    end
    should "boot and run a file and shut down" do
      assert @pipe.gets.is_a?(Hydra::Messages::Runner::RequestFile)

      file = File.join(File.dirname(__FILE__), 'sample_tests', 'assert_true.rb')
      @pipe.write(Hydra::Messages::Runner::RunFile.new(:file => file))
      response = @pipe.gets
      assert response.is_a?(Hydra::Messages::Runner::Results)
      assert response.output =~ /Finished/
      assert_equal file, response.file
      @pipe.write(Hydra::Messages::Runner::Shutdown.new)
    end

    should "run a test" do
      target = File.join(Dir.tmpdir, 'hydra_test.txt')
      FileUtils.rm_f(target)
      assert !File.exists?(target)
      file = File.join(File.dirname(__FILE__), 'sample_tests', 'write_file.rb')
      assert @pipe.gets.is_a?(Hydra::Messages::Runner::RequestFile)
      @pipe.write(Hydra::Messages::Runner::RunFile.new(:file => file))
      response = @pipe.gets
      @pipe.write(Hydra::Messages::Runner::Shutdown.new)
      assert File.exists?(target)
      assert_equal "HYDRA", File.read(target)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hydra-0.3.0 test/test_runner.rb