Sha256: c880cca5c4059e0fef823a7a808f50c3d99ca65417eb490f6c1a8dad9a0f7672

Contents?: true

Size: 926 Bytes

Versions: 2

Compression:

Stored size: 926 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')

require 'test/unit'

require 'nitro/cgi/request'

class TC_Request < Test::Unit::TestCase # :nodoc: all
  class DummyRequest 
    include Nitro::Request
    
    def initialize
      @headers = {}
    end
  end
  
  def test_all
    req = DummyRequest.new

    req.headers['HTTP_HOST'] = 'www.nitroproject.org'
    assert_equal 'nitroproject.org', req.domain
    assert_equal 'www', req.subdomains.first
    
    req.headers['HTTP_HOST'] = 'www.nitroproject.co.uk'
    assert_equal 'nitroproject.co.uk', req.domain(2)

    req.headers['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
    assert req.xhr?

    req.headers['REQUEST_METHOD'] = 'POST'
    
    req.headers['CONTENT_TYPE'] = 'application/x-yaml'
    assert req.yaml_post?
    
    req.instance_variable_set '@post_format', nil
    req.headers['CONTENT_TYPE'] = 'text/xml'
    assert req.xml_post?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.30.0 test/nitro/cgi/tc_request.rb
nitro-0.31.0 test/nitro/cgi/tc_request.rb