Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 52 lines (43 sloc) 1.19 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
require 'rbconfig'
require 'rake/testtask'
require 'rubygems'
require 'bundler'
Bundler.setup
require 'wd_sinatra/app_loader'
require 'active_record'

root = File.expand_path(File.dirname(__FILE__))

Rake::TestTask.new do |t|
  t.libs << "."
  t.libs << 'test'
  t.pattern = "test/**/*_test.rb"
end

task :default => :test

# boot the app
task :setup_app do
  ENV['DONT_CONNECT'] = 'true'
  WDSinatra::AppLoader.server(root)
end

task :environment do
  ENV['DONT_CONNECT'] = nil
  WDSinatra::AppLoader.server(root)
end

WDSinatra::AppLoader.set_loadpath(root)
Dir.glob("lib/tasks/**/*.rake").each do |task_file|
  load task_file
end

namespace :db do
  task :environment do
    ActiveRecord::Base.establish_connection adapter: "sqlite3", database: "db/#{ENV['RACK_ENV']}.sqlite3"
  end

  desc "migrate"
  task(migrate: :environment) do
    ActiveRecord::Base.logger = Logger.new(STDOUT)
    ActiveRecord::Migration.verbose = true
    ActiveRecord::Migrator.migrate("db/migrate")
  end

  desc "rolls back the migration (use steps with STEP=n)"
  task(rollback: :environment) do
    step = ENV["STEP"] ? ENV["STEP"].to_i : 1
    ActiveRecord::Migrator.rollback('db/migrate', step)
  end
end
Something went wrong with that request. Please try again.