Sha256: 62c19d89d92cb16675a27c8d1e44842e0512978917b6daf0d9738d8b97d365a8

Contents?: true

Size: 1.23 KB

Versions: 65

Compression:

Stored size: 1.23 KB

Contents

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

class PipeTest < Test::Unit::TestCase
  context "a pipe" do
    setup do
      @pipe = Hydra::Pipe.new
    end
    teardown do
      @pipe.close
    end
    should "be able to write messages" do
      child = Process.fork do
        @pipe.identify_as_child
        assert_equal "Test Message", @pipe.gets.text
        @pipe.write Hydra::Messages::TestMessage.new(:text => "Message Received")
        @pipe.write Hydra::Messages::TestMessage.new(:text => "Second Message")
      end
      @pipe.identify_as_parent
      @pipe.write Hydra::Messages::TestMessage.new(:text => "Test Message")
      assert_equal "Message Received", @pipe.gets.text
      assert_equal "Second Message", @pipe.gets.text
      Process.wait(child) #ensure it quits, so there is nothing to write to
      assert_raise IOError do
        @pipe.write Hydra::Messages::TestMessage.new(:text => "anyone there?")
      end
    end
    should "not allow writing if unidentified" do
      assert_raise IOError do
        @pipe.write Hydra::Messages::TestMessage.new(:text => "Test Message")
      end
    end
    should "not allow reading if unidentified" do
      assert_raise IOError do
        @pipe.gets
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 8 rubygems

Version Path
ngauthier-hydra-0.24.0 test/pipe_test.rb
nulogy-hydra-0.26.0 test/pipe_test.rb
arturop-hydra-0.25.0 test/pipe_test.rb
arturop-hydra-0.24.0 test/pipe_test.rb
hydra-0.24.0 test/pipe_test.rb
nulogy-hydra-0.23.2.1 test/pipe_test.rb
justinf-hydra-0.23.8 test/pipe_test.rb
justinf-hydra-0.23.7 test/pipe_test.rb
justinf-hydra-0.23.6 test/pipe_test.rb
justinf-hydra-0.23.5 test/pipe_test.rb
justinf-hydra-0.23.4 test/pipe_test.rb
arturop-hydra-0.23.4 test/pipe_test.rb
sskirby-hydra-0.23.3 test/pipe_test.rb
hydra-0.23.3 test/pipe_test.rb
causes-hydra-0.21.0 test/pipe_test.rb
hydra-0.23.2 test/pipe_test.rb
hydra-0.23.1 test/pipe_test.rb
hydra-0.23.0 test/pipe_test.rb
hydra-0.22.2 test/pipe_test.rb
hydra-0.22.1 test/pipe_test.rb