mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Trim down Testing section in the README; link to doc site instead
This commit is contained in:
parent
987d622a52
commit
2f377e26b9
2 changed files with 20 additions and 66 deletions
5
CHANGES
5
CHANGES
|
@ -43,6 +43,11 @@
|
||||||
":session" option to any of the mock request methods. e.g.,
|
":session" option to any of the mock request methods. e.g.,
|
||||||
get '/', {}, :session => { 'foo' => 'bar' }
|
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
|
* The request-level #send_data method from Sinatra 0.3.3 has been added
|
||||||
for compatibility but is deprecated.
|
for compatibility but is deprecated.
|
||||||
|
|
||||||
|
|
81
README.rdoc
81
README.rdoc
|
@ -403,85 +403,34 @@ typically don't have to +use+ them explicitly.
|
||||||
|
|
||||||
== Testing
|
== Testing
|
||||||
|
|
||||||
The Sinatra::Test module includes a variety of helper methods for testing
|
The Sinatra::Test mixin and Sinatra::TestHarness class include a variety of
|
||||||
your Sinatra app. Sinatra includes support for Test::Unit, test-spec, RSpec,
|
helper methods for testing your Sinatra app:
|
||||||
and Bacon through separate source files.
|
|
||||||
|
|
||||||
=== Test::Unit
|
|
||||||
|
|
||||||
require 'sinatra'
|
|
||||||
require 'sinatra/test/unit'
|
|
||||||
require 'my_sinatra_app'
|
require 'my_sinatra_app'
|
||||||
|
require 'test/unit'
|
||||||
|
require 'sinatra/test'
|
||||||
|
|
||||||
class MyAppTest < Test::Unit::TestCase
|
class MyAppTest < Test::Unit::TestCase
|
||||||
|
include Sinatra::Test
|
||||||
|
|
||||||
def test_my_default
|
def test_my_default
|
||||||
get '/'
|
get '/'
|
||||||
assert_equal 'My Default Page!', @response.body
|
assert_equal 'Hello World!', @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_with_agent
|
def test_with_params
|
||||||
get '/', :env => { :agent => 'Songbird' }
|
get '/meet', {:name => 'Frank'}
|
||||||
assert_equal "You're in Songbird!", @response.body
|
assert_equal 'Hello Frank!', @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
...
|
def test_with_rack_env
|
||||||
end
|
get '/', {}, 'HTTP_USER_AGENT => 'Songbird'
|
||||||
|
assert_equal "You're using Songbird!", @response.body
|
||||||
=== 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
|
||||||
end
|
end
|
||||||
|
|
||||||
See Sinatra::Test for more information on +get+, +post+, +put+, and
|
See http://sinatrarb.com/testing.html for more on Sinatra::Test and using it
|
||||||
friends.
|
with other test frameworks such as RSpec, Bacon, and test/spec.
|
||||||
|
|
||||||
== Command line
|
== Command line
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue