Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Integration Testing Cleanup for Metal

#1588

When attempting to test Rails Metal, I ran into several initial problems:

  • PATH_INFO (as used in the example Metal) wasn't being set by the test request
  • response body wasn't available

The attached patch includes the PATH_INFO environment variable in the request, and wraps responses from Rack Middleware and Rails Metal in an AbstractResponse object, thus enabling use of testing helpers like assert_response, et al.

Reported by Jesse Newland · December 17th, 2008 @ 02:35 PM

State: committed
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. Jesse Newland
  2. Repository
    Repository
    • State changed from new to committed

    (from [97a178bfa4d5101dca73ae931cc9c77385d8c97e]) Decorate responses from Rack Middleware and Rails Metal for the purposes of integration testing. A test for the following Metal:

    class Poller < Rails::Rack::Metal
      def call(env)
        if env["PATH_INFO"] =~ /^\/poller/
          [200, {"Content-Type" => "text/plain"}, "Hello World!"]
        else
          super
        end
      end
    end
    
    

    might be tested like so:

    class PollerTest < ActionController::IntegrationTest

    test "poller returns hello world" do
      get "/poller"
      assert_response 200
      assert_response :success
      assert_response :ok
      assert_equal "Hello World!", response.body
    end
    
    

    end

    [#1588 Integration Testing Cleanup for Metal state:committed]

    Signed-off-by: David Heinemeier Hansson david@loudthinking.com http://github.com/rails/rails/co...

    December 17th, 2008 @ 03:00 PM