0.0
No commit activity in last 3 years
No release in over 3 years
A Rack middleware that transforms async requests (using thin + async_sinatra for example) into synchronous requests. Useful for testing Async Sinatra apps with a minimum of changes in your testing environment.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

rack-async2sync¶ ↑

A Rack middleware that transforms async requests (using thin + async_sinatra for example) into synchronous requests Useful for testing with a minimum of changes in your testing environment.

class MyAsyncRackApp < Sinatra::Base
  register Sinatra::Async
  aget '/delay/:n' do |n|
    content_type :txt
    EM.add_timer(n.to_i) { body { "delayed for #{n} seconds" } }
  end
end

class TestRackAsync2Sync < Test::Unit::TestCase
  test "gets the response for an async request" do
    @app = Rack::Async2Sync.new(MyAsyncRackApp)
    get '/delay/1'
    assert last_response.ok?
    assert_equal "delayed for 1 seconds", last_response.body
    assert_equal "text/plain", last_response.headers['Content-Type']
  end
end

Copyright © 2009 Cyril Rohr. See LICENSE for details.