require 'test/unit' require 'rubygems' require 'action_controller' require 'action_controller/test_process' require "#{File.dirname(__FILE__)}/../../../../config/boot.rb" require "#{File.dirname(__FILE__)}/../../../../config/environment.rb" class TestController < ActionController::Base def render_working_action render :text => "This works!" end end class XhrRescueHandlerTest < Test::Unit::TestCase def setup @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @controller = TestController.new @request.host = "www.tangofoxtrot.com" end # Replace this with your real tests. def test_working_route get :render_working_action assert_response :success assert_equal "This works!", @response.body end def test_standard_get_404 get :action_that_doesnt_exists assert_response 404 assert_match_body %r%No action responded to action_that_doesnt_exists% end def test_standard_get_404_with_xhr xhr :get, :action_that_doesnt_exists assert_response 200 assert_match_body %r%window.location='/xhr_error.html% assert_equal @response.content_type, "text/javascript" end def assert_match_body(regex) assert @response.body =~ regex end end