Sha256: b7743520208bbe091b4ed402f61c022c9e708d1e4ef33e756f7f52afc4501fd6

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'test_helper'

module M2R
  class HandlerTest < MiniTest::Unit::TestCase
    def test_lifecycle_for_disconnect
      connection = stub(:receive => disconnect_request)
      connection.stubs(:connection).returns(connection)
      h = TestHandler.new(connection)
      h.listen
      assert_equal [:wait, :request, :disconnect, :all], h.called_methods
    end

    def test_lifecycle_for_upload_start
      connection = stub(:receive => upload_start_request)
      connection.stubs(:connection).returns(connection)
      h = TestHandler.new(connection)
      h.listen
      assert_equal [:wait, :request, :start, :all], h.called_methods
    end

    def test_lifecycle_for_upload_done
      connection = stub(:receive => upload_done_request, :reply => nil)
      connection.stubs(:connection).returns(connection)
      h = TestHandler.new(connection)
      h.listen
      assert_equal [:wait, :request, :done, :process, :after, :reply, :all], h.called_methods
    end

    def disconnect_request
      Request.new("sender", "conn_id", "/path", Headers.new({"METHOD" => "JSON"}), '{"type":"disconnect"}')
    end

    def upload_start_request
      Request.new("sender", "conn_id", "/path", Headers.new({"x-mongrel2-upload-start" => "/tmp/file"}), '')
    end

    def upload_done_request
      Request.new("sender", "conn_id", "/path", Headers.new({"x-mongrel2-upload-start" => "/tmp/file", "x-mongrel2-upload-done" => "/tmp/file"}), '')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
m2r-1.0.0 test/unit/handler_test.rb