Created
September 22, 2009 22:04
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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