Skip to content

Commit

Permalink
Tweaks to doc about using Rack::Test with RSpec.
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Rozet <simon@rozet.name>
  • Loading branch information
baldowl authored and sr committed Jul 26, 2009
1 parent 8b7f1c4 commit 6c6b287
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions testing.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,38 @@ removed in Sinatra `1.0`.

### [RSpec][]

Sinatra can be tested under RSpec using the `spec/interop` library. The
`Rack::Test` module should be included within the `describe` block:
Sinatra can be tested under plain RSpec. The `Rack::Test` module should be
included within the `describe` block:

require 'hello_world' # <-- your sinatra app
require 'spec'
require 'spec/interop/test'
require 'rack/test'

set :environment, :test

describe 'The HelloWorld App' do
include Rack::Test::Methods

def app
Sinatra::Application
end

it "says hello" do
get '/'
last_response.should be_ok
last_response.body.should == 'Hello World'
end
end

Make `Rack::Test` available to all spec contexts by including it in
`Test::Unit::TestCase`:
Make `Rack::Test` available to all spec contexts by including it via
`Spec::Runner`:

require 'spec'
require 'spec/interop/test'
require 'rack/test'

Test::Unit::TestCase.send :include, Rack::Test::Methods
Spec::Runner.configure do |conf|
conf.include Rack::Test::Methods
end

### [Bacon][]

Expand Down

0 comments on commit 6c6b287

Please sign in to comment.