Sha256: 312f71d308dc2d47273d47c38e95f17019979d2a0b7acd3f31047fe057a6dbdc

Contents?: true

Size: 909 Bytes

Versions: 6

Compression:

Stored size: 909 Bytes

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')

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.nitrohq.com'
    assert_equal 'nitrohq.com', req.domain
    assert_equal 'www', req.subdomains.first
    
    req.headers['HTTP_HOST'] = 'www.nitrohq.co.uk'
    assert_equal 'nitrohq.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

6 entries across 6 versions & 1 rubygems

Version Path
nitro-0.24.0 test/nitro/cgi/tc_request.rb
nitro-0.25.0 test/nitro/cgi/tc_request.rb
nitro-0.26.0 test/nitro/cgi/tc_request.rb
nitro-0.27.0 test/nitro/cgi/tc_request.rb
nitro-0.28.0 test/nitro/cgi/tc_request.rb
nitro-0.29.0 test/nitro/cgi/tc_request.rb