Skip to content

Instantly share code, notes, and snippets.

@mudge
Created September 22, 2009 22:04
Show Gist options
  • Save mudge/191473 to your computer and use it in GitHub Desktop.
Save mudge/191473 to your computer and use it in GitHub Desktop.
Unit test for a Sequel-using Sinatra application that rolls back DB changes on each test.
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