-
Notifications
You must be signed in to change notification settings - Fork 51
/
Rakefile
29 lines (22 loc) · 825 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
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'active_record'
RSpec::Core::RakeTask.new(:spec)
task :setup_and_run_spec do |rake_task|
puts "<:#{rake_task.name}> Ensuring database is prepared..."
# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'
ENV['DATABASE_URL'] ||= 'postgresql://localhost/upsert_test'
require 'active_record/connection_adapters/postgresql_adapter'
require File.expand_path('../spec/dummy/config/environment.rb', __FILE__)
if Rails.version >= '5.2.0'
ActiveRecord::Base.connection.migrations_paths << 'spec/dummy/db/migrate'
end
include ActiveRecord::Tasks
DatabaseTasks.db_dir = 'spec/dummy/db'
DatabaseTasks.drop_current
DatabaseTasks.create_current
DatabaseTasks.migrate
Rake::Task['spec'].invoke
end
task default: :setup_and_run_spec