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