Permalink
Browse files

Bootstrapping of changes to doc for testing

  • Loading branch information...
1 parent 88d7b38 commit 78cbc0e5e42a00d4fcff3a0b698076e23b7d4534 @dashdotat dashdotat committed with sr Feb 22, 2009
Showing with 91 additions and 0 deletions.
  1. +4 −0 documentation.markdown
  2. +87 −0 testing.markdown
View
@@ -10,6 +10,10 @@ Documentation
A whirlwind tour of Sinatra's most interesting features.
+### [Testing](testing.html)
+
+Guide to testing Sinatra
+
### [Frequently Asked Questions](faq.html)
Answers to those questions most frequently asked on the mailing list and
View
@@ -0,0 +1,87 @@
+---
+title: Testing Sinatra
+layout: default
+---
+
+## 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.
+
+### Test::Unit
+ require 'sinatra'
+ require 'sinatra/test/unit'
+ require 'my_sinatra_app'
+
+ class MyAppTest < Test::Unit::TestCase
+ def test_my_default
+ get '/'
+ assert_equal 'My Default Page!', @response.body
+ end
+
+ 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
+ get '/'
+ should.be.ok
+ body.should.equal 'My Default Page!'
+ 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!'
+ 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'
+ end
+ end
+
+See Sinatra::Test for more information on <tt>get</tt>, <tt>post</tt>, <tt>put</tt> and friends.
+

0 comments on commit 78cbc0e

Please sign in to comment.