-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
54 lines (45 loc) · 1.14 KB
/
Rakefile
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
53
54
require 'sinatra/activerecord/rake'
require 'sinatra/activerecord'
require 'sinatra/activerecord/rake'
require "./app/api"
$:.unshift File.expand_path("./app/", __FILE__)
require 'rake/testtask'
desc "Load the environment"
task :environment do
env = ENV["SINATRA_ENV"] || "test"
databases = YAML.load_file("./config/database.yml")
ActiveRecord::Base.establish_connection(databases[env])
end
namespace :db do
desc "Migrate the database"
task(:migrate => :environment) do
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Migration.verbose = true
ActiveRecord::Migrator.migrate("db/migrate")
end
end
# namespace :db do
# desc "migrate your database"
# task :migrate do
# require 'bundler'
# Bundler.require
# require './config/environment'
# ActiveRecord::Migrator.migrate('db/migrate')
# end
# end
# namespace :db do
# task :load_config do
# require "./app/api"
# end
# end
task :console do
system "./script/console"
end
task :server do
system "bundle exec rackup -p 5000"
end
Rake::TestTask.new do |t|
t.pattern = "test/**/*_test.rb"
t.pattern = "test/**/test_*.rb"
end
task default: :test