Skip to content
Browse files

Words.

  • Loading branch information...
1 parent 7bd1d01 commit 0a0d32cb9d3eb458dc709b5443b7e7c67e049357 @phiggins committed Jun 14, 2011
Showing with 47 additions and 8 deletions.
  1. +47 −8 README.txt
View
55 README.txt
@@ -1,26 +1,65 @@
-= thin_async_test
+= thin-async-test
-* FIX (url)
+* https://github.com/phiggins/thin-async-test
== DESCRIPTION:
-FIX (describe your package)
+Rack middleware to convince thin-async and rack-test to play nicely.
== FEATURES/PROBLEMS:
-* FIX (list of features or problems)
+* Allows async thin apps to be tested like regular synchronous ones.
+* Doesn't interfere with regular synchronous apps.
+* Stops and starts the eventmachine reactor for each test, so test speed suffers.
== SYNOPSIS:
- FIX (code sample of usage)
+ require 'thin/async'
+
+ # Step 1: Make your rack app that uses thin and thin-async's AsyncResponse.
+ class MyRackApp
+ def call(env)
+ response = Thin::AsyncResponse.new(env)
+
+ response.headers["X-Foo"] = "bar"
+
+ response << "Here's some body..."
+
+ EM.add_timer(0.1) do
+ response << "long running action"
+
+ response.done
+ end
+
+ response.finish
+ end
+ end
+
+ # Step 2: Create your test class with rack-test.
+ class TestMyRackApp < MiniTest::Unit::TestCase
+ include Rack::Test::Methods
+
+ # Step 3: Define your app method, but wrap it with a Thin::Async::Test
+ def app
+ Thin::Async::Test.new(MyRackApp)
+ end
+
+ # Step 4: You can test your async rack actions like syncronous ones.
+ def test_my_rack_app
+ get("/")
+
+ assert_equal 200, last_response.status
+ end
+ end
== REQUIREMENTS:
-* FIX (list of requirements)
+* Designed to work with thin and thin-async, but could potentially work with other stuff.
+* Tested with eventmachine-1.0.0.beta.3 and ruby-1.9.2-p180.
== INSTALL:
-* FIX (sudo gem install, anything else)
+Nothing special.
== DEVELOPERS:
@@ -35,7 +74,7 @@ and generate the RDoc.
(The MIT License)
-Copyright (c) 2011 FIX
+Copyright (c) 2011 Pete Higgins
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

0 comments on commit 0a0d32c

Please sign in to comment.
Something went wrong with that request. Please try again.