-
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathRakefile
More file actions
88 lines (78 loc) · 2.53 KB
/
Rakefile
File metadata and controls
88 lines (78 loc) · 2.53 KB
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
82
83
84
85
86
87
88
# frozen_string_literal: true
require "bundler/gem_tasks"
require "pathname"
# Remove Bundler's default `release` task — it bypasses the custom release flow
# (CHANGELOG version detection, npm publish, GitHub release sync, etc.).
# The custom `release` task in rakelib/release.rake replaces it.
Rake::Task[:release].clear
desc "Run all specs"
task test: ["run_spec:all_specs"]
task default: :test
namespace :run_spec do
desc "Run shakapacker specs"
task :gem do
puts "Running Shakapacker gem specs"
sh("bundle exec rspec spec/shakapacker/*_spec.rb")
end
desc "Run specs in the dummy app with webpack"
task :dummy do
puts "Running dummy app specs with webpack"
spec_dummy_dir = Pathname.new(File.join("spec", "dummy")).realpath
Bundler.with_unbundled_env do
sh_in_dir(".", "yalc publish")
sh_in_dir(spec_dummy_dir, [
"bundle install",
"yarn install",
"yalc add shakapacker",
"yarn install",
"bin/test-bundler webpack",
"NODE_ENV=test RAILS_ENV=test bin/shakapacker",
"bundle exec rspec"
])
end
end
desc "Run specs in the dummy app with rspack"
task :dummy_with_rspack do
puts "Running dummy app specs with rspack"
spec_dummy_dir = Pathname.new(File.join("spec", "dummy")).realpath
Bundler.with_unbundled_env do
sh_in_dir(".", "yalc publish")
sh_in_dir(spec_dummy_dir, [
"bundle install",
"yarn install",
"yalc add shakapacker",
"yarn install",
"bin/test-bundler rspack",
"NODE_ENV=test RAILS_ENV=test bin/shakapacker",
"bundle exec rspec"
])
end
end
desc "Run specs in the dummy-rspack app"
task :dummy_rspack do
puts "Running dummy-rspack app specs"
spec_dummy_dir = Pathname.new(File.join("spec", "dummy-rspack")).realpath
Bundler.with_unbundled_env do
sh_in_dir(".", "yalc publish")
sh_in_dir(spec_dummy_dir, [
"bundle install",
"yarn install",
"yalc add shakapacker",
"yarn install",
"NODE_ENV=test RAILS_ENV=test npm exec --no -- rspack build --config config/rspack/rspack.config.js",
"bundle exec rspec"
])
end
end
desc "Run generator specs"
task :generator do
sh("bundle exec rspec spec/generator_specs/*_spec.rb")
end
desc "Run all specs"
task all_specs: %i[gem dummy dummy_with_rspack dummy_rspack generator] do
puts "Completed all RSpec tests"
end
end
def sh_in_dir(dir, *shell_commands)
Shakapacker::Utils::Misc.sh_in_dir(dir, *shell_commands)
end