-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
38 lines (31 loc) · 869 Bytes
/
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
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.ruby_opts = %w( -I . )
end
RuboCop::RakeTask.new(:rubocop)
task default: [:spec, :rubocop]
namespace :db do
def db_client
require 'mysql2'
@client ||= Mysql2::Client.new(
host: 'localhost',
username: 'root')
end
task :create do
db_client.query('create database if not exists health_check;')
db_client.query <<-SQL
create table if not exists health_check.state (
host_name varchar(128) not null,
available tinyint(1) not null default 1,
unique index (host_name));
SQL
end
task :seed do
db_client.query <<-SQL
insert ignore into health_check.state(host_name, available)
values ('dev.local', 1), ('test.local', 1);
SQL
end
task :setup => [:create, :seed]
end