-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
82 lines (65 loc) · 1.78 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
75
76
77
78
79
80
81
# This rakefile based heavily upon one I found here:
# https://github.com/zapnap/sinatra-template
# (MIT License)
require 'rubygems'
require 'bundler/setup'
#require 'rspec/core/rake_task' unless ENV['RACK_ENV'] == 'production'
task :default => :test
task :test => [:'set_env:test', :spec]
if !defined?(RSpec)
puts "spec targets require RSpec"
else
desc "Run all rspec tests (or provide a specific file as an argument)"
RSpec::Core::RakeTask.new(:spec, :file) do |t, args|
str = args[:file] || ''
str += '*' unless str.empty?
t.pattern = "test/**/*#{str}_spec.rb"
puts t.pattern
if RUBY_PLATFORM =~ /(win|w)32$/
t.rspec_opts = ['-fs']
else
t.rspec_opts = ['-cfs']
end
end
end
desc 'Start an interactive test shell'
task :shell => [:'set_env:dev', :environment] do
require 'pry'
IRB = Pry
ARGV.clear
IRB.start
end
desc 'Launch a local demo'
task :demo do
system 'rackup'
end
desc 'Start within rdebug'
task :debug do
system 'rdebug rackup'
end
namespace :db do
desc 'Auto-migrate the database (destroys data)'
task :migrate => :environment do
DataMapper.auto_migrate!
end
desc 'Auto-upgrade the database (preserves data)'
task :upgrade => :environment do
DataMapper.auto_upgrade!
end
desc 'Populate the database with fresh data!'
task :populate => :environment do
require_relative 'scripts/db/populate/user.rb'
puts 'Populating the database...'
populate_users!
puts 'done!'
end
end
# These are used to force a particular environment. Default is development.
namespace :set_env do
task :dev do ENV['RACK_ENV'] = 'development' end
task :prod do ENV['RACK_ENV'] = 'production' end
task :test do ENV['RACK_ENV'] = 'testing' end
end
task :environment do
require_relative 'environment'
end