-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
74 lines (62 loc) · 1.53 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# frozen_string_literal: true
require "bundler"
require "active_record"
require "rake"
require "rspec"
require "git"
require "rspec/core/rake_task"
require "rubocop/rake_task"
require "sinatra/activerecord/rake"
require_relative "app"
task default: %i(rubocop spec)
RSpec::Core::RakeTask.new do |t|
t.pattern = "spec/**/*spec.rb"
end
RuboCop::RakeTask.new
include ActiveRecord::Tasks
raw_conf = File.read(File.join(__dir__, "config", "config.yml"))
conf = YAML.load(ERB.new(raw_conf).result)
ActiveRecord::Base.configurations = conf["database"]
namespace :db do
desc "create all the databases from config.yml"
namespace :create do
task(:all) do
DatabaseTasks.create_all
end
end
desc "drop all the databases from config.yml"
namespace :drop do
task(:all) do
DatabaseTasks.drop_all
end
end
desc "redo last migration"
task redo: ["db:rollback", "db:migrate"]
end
desc "prepares everything for tests"
task :testup do
system("rake db:migrate RACK_ENV=test")
system("rake seed RACK_ENV=test")
end
desc "create release on github"
task(:release) do
begin
require "git"
g = Git.open(File.dirname(__FILE__))
new_tag = Gnc.version
g.add_tag("v#{new_tag}")
g.add(all: true)
g.commit(":shipit: Releasing version #{new_tag}")
g.push(tags: true)
rescue Git::GitExecuteError => e
puts e
end
end
desc "populate seed data for tests"
task :seed do
require_relative "db/seed"
end
desc "open an irb session preloaded with this library"
task :console do
sh "irb -r pp -r ./app.rb"
end