blob: bda8c7b6c8a37821137ba722ff59f4bd1201acf5 (
plain) (
blame)
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
|
require "rake/testtask"
require "pathname"
require "open3"
require "action_cable"
dir = File.dirname(__FILE__)
task default: :test
task package: %w( assets:compile assets:verify )
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = Dir.glob("#{dir}/test/**/*_test.rb")
t.warning = true
t.verbose = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end
namespace :test do
task :isolated do
Dir.glob("test/**/*_test.rb").all? do |file|
sh(Gem.ruby, "-w", "-Ilib:test", file)
end || raise("Failures")
end
task :integration do
require "blade"
if ENV["CI"]
Blade.start(interface: :ci)
else
Blade.start(interface: :runner)
end
end
end
namespace :assets do
desc "Compile Action Cable assets"
task :compile do
require "blade"
require "sprockets"
require "sprockets/export"
Blade.build
end
desc "Verify compiled Action Cable assets"
task :verify do
file = "lib/assets/compiled/action_cable.js"
pathname = Pathname.new("#{dir}/#{file}")
print "[verify] #{file} exists "
if pathname.exist?
puts "[OK]"
else
$stderr.puts "[FAIL]"
fail
end
print "[verify] #{file} is a UMD module "
if pathname.read =~ /module\.exports.*define\.amd/m
puts "[OK]"
else
$stderr.puts "[FAIL]"
fail
end
print "[verify] #{dir} can be required as a module "
stdout, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{dir}');")
if status.success?
puts "[OK]"
else
$stderr.puts "[FAIL]\n#{stderr}"
fail
end
end
end
|