Skip to content

Instantly share code, notes, and snippets.

@sohooo
Forked from mudge/gist:191473
Created December 19, 2009 21:01
Show Gist options
  • Save sohooo/260245 to your computer and use it in GitHub Desktop.
Save sohooo/260245 to your computer and use it in GitHub Desktop.
Sinatra Rack Testing
require 'sinatra_app'
require 'test/unit'
require 'rack/test'
set :environment, :test
class SinatraAppTest < Test::Unit::TestCase
include Rack::Test::Methods
# Make all tests transactional.
def run(result)
DB.transaction do
super
raise(Sequel::Rollback)
end
end
def app
Sinatra::Application
end
def test_index
get '/'
assert last_response.ok?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment