diff --git a/README.rdoc b/README.rdoc index efaf4a94..da6df127 100644 --- a/README.rdoc +++ b/README.rdoc @@ -18,27 +18,34 @@ request helpers feature. == Examples + require "test/unit" require "rack/test" - + class HomepageTest < Test::Unit::TestCase include Rack::Test::Methods - + def app - MyApp.new + app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['All responses are OK']] } + builder = Rack::Builder.new + builder.run app end - - def test_redirect_logged_in_users_to_dashboard - authorize "bryan", "secret" + + def test_response_is_ok get "/" - follow_redirect! - - assert_equal "http://example.org/redirected", last_request.url + assert last_response.ok? + assert_equal last_response.body, "All responses are OK" end - + + def test_response_is_ok_for_other_paths + get "/other_paths" + + assert last_response.ok? + assert_equal last_response.body, "All responses are OK" + end + end - If you want to test one app in isolation, you just return that app as shown above. But if you want to test the entire app stack, including middlewares, cascades etc. you need to parse the app defined in config.ru. OUTER_APP = Rack::Builder.parse_file('config.ru').first