aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/Rakefile
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable/Rakefile')
-rw-r--r--actioncable/Rakefile87
1 files changed, 49 insertions, 38 deletions
diff --git a/actioncable/Rakefile b/actioncable/Rakefile
index 5ba7b7f7f6..226d171104 100644
--- a/actioncable/Rakefile
+++ b/actioncable/Rakefile
@@ -1,19 +1,17 @@
-require 'rake/testtask'
-require 'pathname'
-require 'sprockets'
-require 'coffee-script'
-require 'action_cable'
+# frozen_string_literal: true
-dir = File.dirname(__FILE__)
+require "rake/testtask"
+require "pathname"
+require "open3"
+require "action_cable"
-task :default => :test
+task default: :test
-task :package => "assets:compile"
-task "package:clean" => "assets:clean"
+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.test_files = Dir.glob("#{__dir__}/test/**/*_test.rb")
t.warning = true
t.verbose = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
@@ -22,44 +20,57 @@ end
namespace :test do
task :isolated do
Dir.glob("test/**/*_test.rb").all? do |file|
- sh(Gem.ruby, '-w', '-Ilib:test', file)
- end or raise "Failures"
+ 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
- root_path = Pathname.new(dir)
- destination_path = root_path.join("lib/assets/compiled")
-
- desc "Compile dist/action_cable.js"
+ desc "Compile Action Cable assets"
task :compile do
- puts 'Compiling Action Cable assets...'
+ require "blade"
+ require "sprockets"
+ require "sprockets/export"
+ Blade.build
+ end
- precompile_list = %w(action_cable.js)
+ desc "Verify compiled Action Cable assets"
+ task :verify do
+ file = "lib/assets/compiled/action_cable.js"
+ pathname = Pathname.new("#{__dir__}/#{file}")
- environment = Sprockets::Environment.new
- environment.gzip = false
- Pathname.glob(root_path.join("app/assets/*/")) do |subdir|
- environment.append_path subdir
+ print "[verify] #{file} exists "
+ if pathname.exist?
+ puts "[OK]"
+ else
+ $stderr.puts "[FAIL]"
+ fail
end
- compile_path = root_path.join("tmp/sprockets")
- compile_path.rmtree if compile_path.exist?
- compile_path.mkpath
-
- manifest = Sprockets::Manifest.new(environment.index, compile_path)
- manifest.compile(precompile_list)
-
- destination_path.rmtree if destination_path.exist?
- manifest.assets.each do |path, fingerprint_path|
- destination_path.join(path).dirname.mkpath
- FileUtils.cp(compile_path.join(fingerprint_path), destination_path.join(path))
+ print "[verify] #{file} is a UMD module "
+ if pathname.read =~ /module\.exports.*define\.amd/m
+ puts "[OK]"
+ else
+ $stderr.puts "[FAIL]"
+ fail
end
- puts 'Done'
- end
-
- task :clean do
- destination_path.rmtree if destination_path.exist?
+ print "[verify] #{__dir__} can be required as a module "
+ _, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{__dir__}');")
+ if status.success?
+ puts "[OK]"
+ else
+ $stderr.puts "[FAIL]\n#{stderr}"
+ fail
+ end
end
end