From e3ae7c04928d1afea9a6abf9736cb9bf6071ac30 Mon Sep 17 00:00:00 2001 From: Dennis Sivia Date: Wed, 17 May 2017 07:23:33 +0200 Subject: [PATCH] Switches README format to markdown (#176) As discussed in github issue #175 the format is supposed to be changed to markdown. This Change changes the file extension and formatting of the file. In addition the copyright and maintainer sections have been updated and/or removed. --- README.md | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.rdoc | 91 -------------------------------------------------- 2 files changed, 96 insertions(+), 91 deletions(-) create mode 100644 README.md delete mode 100644 README.rdoc diff --git a/README.md b/README.md new file mode 100644 index 00000000..9c2d66f4 --- /dev/null +++ b/README.md @@ -0,0 +1,96 @@ +# Rack::Test +[](https://travis-ci.org/rack-test/rack-test) +[](https://codeclimate.com/github/brynary/rack-test) +[](https://codeclimate.com/github/brynary/rack-test) + +Code: https://github.com/rack-test/rack-test + +## Description + +Rack::Test is a small, simple testing API for Rack apps. It can be used on its +own or as a reusable starting point for Web frameworks and testing libraries +to build on. + +## Features + +* Maintains a cookie jar across requests +* Easily follow redirects when desired +* Set request headers to be used by all subsequent requests +* Small footprint. Approximately 200 LOC + +## Examples +```ruby +require "test/unit" +require "rack/test" + +class HomepageTest < Test::Unit::TestCase + include Rack::Test::Methods + + def app + app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['All responses are OK']] } + builder = Rack::Builder.new + builder.run app + end + + def test_response_is_ok + get "/" + + 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. + +```ruby +OUTER_APP = Rack::Builder.parse_file("config.ru").first + +class TestApp < Test::Unit::TestCase + include Rack::Test::Methods + + def app + OUTER_APP + end + + def test_root + get "/" + assert last_response.ok? + end +end +``` + + +## Install + +To install the latest release as a gem: + +`gem install rack-test` + +Or via Bundler: + +`gem "rack-test", require: "rack/test"` + +## Authors + +- Contributions from Bryan Helmkamp, Simon Rozet, Pat Nakajima and others +- Much of the original code was extracted from Merb 1.0's request helper + +## License +`rack-test` is released under the [MIT License](MIT-LICENSE.txt). + +## Contribution + +Contributions are welcome. Please make sure to: + +* Use a regular forking workflow +* write tests for the new / changed behaviour. +* Provide an explanation/motivation in your commit message / PR message +* Ensure History.txt is updated diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index 684c40d4..00000000 --- a/README.rdoc +++ /dev/null @@ -1,91 +0,0 @@ -= Rack::Test {}[https://travis-ci.org/rack-test/rack-test] {}[https://codeclimate.com/github/brynary/rack-test] {}[https://codeclimate.com/github/brynary/rack-test] - -- Code: http://github.com/rack-test/rack-test - -== Description - -Rack::Test is a small, simple testing API for Rack apps. It can be used on its -own or as a reusable starting point for Web frameworks and testing libraries -to build on. - -== Features - -* Maintains a cookie jar across requests -* Easily follow redirects when desired -* Set request headers to be used by all subsequent requests -* Small footprint. Approximately 200 LOC - -== Examples - - require "test/unit" - require "rack/test" - - class HomepageTest < Test::Unit::TestCase - include Rack::Test::Methods - - def app - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['All responses are OK']] } - builder = Rack::Builder.new - builder.run app - end - - def test_response_is_ok - get "/" - - 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 - - class TestApp < Test::Unit::TestCase - include Rack::Test::Methods - - def app - OUTER_APP - end - - def test_root - get "/" - assert last_response.ok? - end - end - - -== Install - -To install the latest release as a gem: - - gem install rack-test - -Or via Bundler: - - gem "rack-test", require: "rack/test" - -== Authors - -- Maintained by {Bryan Helmkamp}[mailto:bryan@brynary.com] -- Contributions from Simon Rozet, Pat Nakajima and others -- Much of the original code was extracted from Merb 1.0's request helper - -== License - -Copyright (c) 2008-2013 Bryan Helmkamp -See MIT-LICENSE.txt in this directory. - -== Releasing - -* Ensure History.txt is up-to-date -* Bump VERSION in lib/rack/test.rb -* thor :release