forked from fly-apps/dockerfile-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
46 lines (39 loc) · 1.3 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
# frozen_string_literal: true
require "bundler/gem_tasks"
# Run `rake release` to release a new version of the gem.
require "rake/testtask"
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList["test/test*.rb"]
t.verbose = true
end
namespace :test do
task :capture do
ENV["TEST_CAPTURE"] = "true"
Rake::Task[:test].invoke
end
task :rubocop do
sh "rubocop"
end
task :system do
rm_rf "test/tmp/system_test"
Dir.chdir "test/tmp" do
sh "rails new system_test --javascript esbuild"
Dir.chdir "system_test"
sh "bundle config disable_local_branch_check true"
sh "bundle config set --local local.dockerfile-rails #{__dir__}"
sh "bundle add dockerfile-rails --group development " +
"--git https://github.com/rubys/dockerfile-rails.git"
sh "bin/rails generate dockerfile"
cp "#{__dir__}/test/docker-entrypoint", "bin"
IO.write "config/routes.rb",
'Rails.application.routes.draw {get "/up", to: proc {[200, {}, ["ok"]]}}'
sh "docker buildx build . --load -t system:test"
key = IO.read("config/master.key")
sh "docker run -p 3000:3000 -e RAILS_MASTER_KEY=#{key} --rm system:test"
end
ensure
rm_rf "test/tmp/system_test" unless ENV["TEST_KEEP"]
end
task all: %w(test:rubocop test test:system)
end