Sha256: 93f1297ce0f9cfcbc3aeefa2c660d58304e674a47dc9028b50ac66d11d4635f3

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require_relative "spec_helper"

module Nyara
  describe [Controller, Request] do
    class DelegateController < Controller
    end

    before :all do
      Ext.set_skip_on_url true
    end

    after :all do
      Ext.set_skip_on_url false
    end

    before :each do
      @client, @server = Socket.pair :UNIX, :STREAM
      Ext.set_nonblock @server.fileno
      @request = Ext.handle_request @server.fileno
      Ext.set_request_attrs @request, {
        method_num: HTTP_METHODS['GET'],
        path: '/search',
        param: ParamHash.new.tap{|h| h['q'] = 'nyara' },
        fiber: Fiber.new{},
        scope: '/scope',
        header: HeaderHash.new.tap{|h| h['Accept'] = 'en-US' }
        # ext: nil
        # response_header:
        # response_header_extra_lines:
      }
      @c = DelegateController.new @request
    end

    it "#content_type" do
      @c.content_type :js
      assert_equal 'application/javascript', @request.response_content_type
    end

    it "#status" do
      assert_raise ArgumentError do
        @c.status 1000
      end
      @c.status 404
      assert_equal 404, @request.status
    end

    it "request header" do
      assert_equal 'en-US', @c.header['accept']
    end

    it "set response header and send" do
      pending
      @c.set_header
      @c.add_header_line
      @c.send_header
      @client
    end

    it "set / delete / clear cookie" do
      pending
    end

    it "#session" do
      pending
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyara-0.0.1.pre spec/request_delegate_spec.rb