Skip to content

Commit

Permalink
Use an in memory db while testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Rasch committed May 31, 2012
1 parent a914e05 commit 7ea4714
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions db/dao.rb
Expand Up @@ -10,12 +10,17 @@ def db
private

def connect
dir = File.dirname(__FILE__)
env = ENV["RACK_ENV"] || "development"
db_file = File.join(dir, "#{env}.db")
@db = Sequel.sqlite(db_file)
@db.loggers << Logger.new($stdout) if env == "development"
@db
if env == "test"
@db = Sequel.sqlite
else
dir = File.dirname(__FILE__)
env = ENV["RACK_ENV"] || "development"
db_file = File.join(dir, "#{env}.db")
@db = Sequel.sqlite(db_file)
@db.loggers << Logger.new($stdout) if env == "development"
@db
end
end
end
end

0 comments on commit 7ea4714

Please sign in to comment.