Skip to content

Commit

Permalink
Trim down Testing section in the README; link to doc site instead
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomayko committed Mar 2, 2009
1 parent 987d622 commit 2f377e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 66 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Expand Up @@ -43,6 +43,11 @@
":session" option to any of the mock request methods. e.g.,
get '/', {}, :session => { 'foo' => 'bar' }

* The testing framework specific files ('sinatra/test/spec',
'sinatra/test/bacon', 'sinatra/test/rspec', etc.) have been deprecated.
See http://sinatrarb.com/testing.html for instructions on setting up
a testing environment with these frameworks.

* The request-level #send_data method from Sinatra 0.3.3 has been added
for compatibility but is deprecated.

Expand Down
81 changes: 15 additions & 66 deletions README.rdoc
Expand Up @@ -403,85 +403,34 @@ typically don't have to +use+ them explicitly.

== Testing

The Sinatra::Test module includes a variety of helper methods for testing
your Sinatra app. Sinatra includes support for Test::Unit, test-spec, RSpec,
and Bacon through separate source files.
The Sinatra::Test mixin and Sinatra::TestHarness class include a variety of
helper methods for testing your Sinatra app:

=== Test::Unit

require 'sinatra'
require 'sinatra/test/unit'
require 'my_sinatra_app'
require 'test/unit'
require 'sinatra/test'

class MyAppTest < Test::Unit::TestCase
def test_my_default
get '/'
assert_equal 'My Default Page!', @response.body
end
include Sinatra::Test

def test_with_agent
get '/', :env => { :agent => 'Songbird' }
assert_equal "You're in Songbird!", @response.body
end

...
end

=== Test::Spec

Install the test-spec gem and require <tt>'sinatra/test/spec'</tt> before
your app:

require 'sinatra'
require 'sinatra/test/spec'
require 'my_sinatra_app'

describe 'My app' do
it "should show a default page" do
def test_my_default
get '/'
should.be.ok
body.should.equal 'My Default Page!'
assert_equal 'Hello World!', @response.body
end

...
end

=== RSpec

Install the rspec gem and require <tt>'sinatra/test/rspec'</tt> before
your app:

require 'sinatra'
require 'sinatra/test/rspec'
require 'my_sinatra_app'

describe 'My app' do
it 'should show a default page' do
get '/'
@response.should be_ok
@response.body.should == 'My Default Page!'
def test_with_params
get '/meet', {:name => 'Frank'}
assert_equal 'Hello Frank!', @response.body
end

...

end

=== Bacon

require 'sinatra'
require 'sinatra/test/bacon'
require 'my_sinatra_app'

describe 'My app' do
it 'should be ok' do
get '/'
should.be.ok
body.should == 'Im OK'
def test_with_rack_env
get '/', {}, 'HTTP_USER_AGENT => 'Songbird'
assert_equal "You're using Songbird!", @response.body
end
end

See Sinatra::Test for more information on +get+, +post+, +put+, and
friends.
See http://sinatrarb.com/testing.html for more on Sinatra::Test and using it
with other test frameworks such as RSpec, Bacon, and test/spec.

== Command line

Expand Down

0 comments on commit 2f377e2

Please sign in to comment.