Skip to content

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.

License

Notifications You must be signed in to change notification settings

crohr/rack-async2sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages