Recommend Rack::Test in README / note Sinatra::Test deprecation

This commit is contained in:
Ryan Tomayko 2009-05-18 05:17:00 -07:00
parent b48ed22ba9
commit c831278af9
1 changed files with 16 additions and 12 deletions

View File

@ -437,34 +437,38 @@ typically don't have to +use+ them explicitly.
== Testing
The Sinatra::Test mixin and Sinatra::TestHarness class include a variety of
helper methods for testing your Sinatra app:
Sinatra tests can be written using any Rack-based testing library
or framework. {Rack::Test}[http://gitrdoc.com/brynary/rack-test] is
recommended:
require 'my_sinatra_app'
require 'test/unit'
require 'sinatra/test'
require 'rack/test'
class MyAppTest < Test::Unit::TestCase
include Sinatra::Test
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_my_default
get '/'
assert_equal 'Hello World!', @response.body
assert_equal 'Hello World!', last_response.body
end
def test_with_params
get '/meet', {:name => 'Frank'}
assert_equal 'Hello Frank!', @response.body
get '/meet', :name => 'Frank'
assert_equal 'Hello Frank!', last_response.body
end
def test_with_rack_env
get '/', {}, :agent => 'Songbird'
assert_equal "You're using Songbird!", @response.body
get '/', {}, 'HTTP_USER_AGENT' => 'Songbird'
assert_equal "You're using Songbird!", last_response.body
end
end
See http://www.sinatrarb.com/testing.html for more on Sinatra::Test and using it
with other test frameworks such as RSpec, Bacon, and test/spec.
NOTE: The built-in Sinatra::Test module and Sinatra::TestHarness class
are deprecated as of the 0.9.2 release.
== Command line