2017-07-16 13:10:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:28:46 -04:00
|
|
|
require "rake/testtask"
|
|
|
|
require "pathname"
|
2017-03-11 12:33:11 -05:00
|
|
|
require "open3"
|
2016-08-06 13:28:46 -04:00
|
|
|
require "action_cable"
|
2015-01-15 12:28:02 -05:00
|
|
|
|
2016-08-06 13:32:32 -04:00
|
|
|
task default: :test
|
2015-01-15 12:28:02 -05:00
|
|
|
|
2017-03-11 12:33:11 -05:00
|
|
|
task package: %w( assets:compile assets:verify )
|
2016-01-31 13:01:03 -05:00
|
|
|
|
2015-12-14 10:38:37 -05:00
|
|
|
Rake::TestTask.new do |t|
|
2015-01-15 12:28:02 -05:00
|
|
|
t.libs << "test"
|
2017-05-15 10:17:28 -04:00
|
|
|
t.test_files = Dir.glob("#{__dir__}/test/**/*_test.rb")
|
2015-12-14 10:38:37 -05:00
|
|
|
t.warning = true
|
2015-01-15 12:28:02 -05:00
|
|
|
t.verbose = true
|
2015-12-14 10:38:37 -05:00
|
|
|
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
|
2015-01-15 12:28:02 -05:00
|
|
|
end
|
2016-01-30 15:41:14 -05:00
|
|
|
|
2016-03-20 20:00:46 -04:00
|
|
|
namespace :test do
|
|
|
|
task :isolated do
|
|
|
|
Dir.glob("test/**/*_test.rb").all? do |file|
|
2016-08-06 13:28:46 -04:00
|
|
|
sh(Gem.ruby, "-w", "-Ilib:test", file)
|
2016-09-01 17:41:49 -04:00
|
|
|
end || raise("Failures")
|
2016-03-20 20:00:46 -04:00
|
|
|
end
|
2016-05-09 09:36:53 -04:00
|
|
|
|
2016-05-09 15:42:28 -04:00
|
|
|
task :integration do
|
2016-10-21 18:19:44 -04:00
|
|
|
require "blade"
|
2016-08-06 13:28:46 -04:00
|
|
|
if ENV["CI"]
|
2016-05-09 15:42:28 -04:00
|
|
|
Blade.start(interface: :ci)
|
|
|
|
else
|
|
|
|
Blade.start(interface: :runner)
|
|
|
|
end
|
2016-05-09 09:36:53 -04:00
|
|
|
end
|
2016-03-20 20:00:46 -04:00
|
|
|
end
|
|
|
|
|
2016-01-30 15:41:14 -05:00
|
|
|
namespace :assets do
|
2016-05-23 09:37:16 -04:00
|
|
|
desc "Compile Action Cable assets"
|
2016-01-30 15:41:14 -05:00
|
|
|
task :compile do
|
2016-10-21 18:19:44 -04:00
|
|
|
require "blade"
|
2017-03-11 12:33:11 -05:00
|
|
|
require "sprockets"
|
|
|
|
require "sprockets/export"
|
2016-05-23 09:37:16 -04:00
|
|
|
Blade.build
|
2016-01-30 15:41:14 -05:00
|
|
|
end
|
2017-03-11 12:33:11 -05:00
|
|
|
|
|
|
|
desc "Verify compiled Action Cable assets"
|
|
|
|
task :verify do
|
|
|
|
file = "lib/assets/compiled/action_cable.js"
|
2017-05-15 10:17:28 -04:00
|
|
|
pathname = Pathname.new("#{__dir__}/#{file}")
|
2017-03-11 12:33:11 -05:00
|
|
|
|
|
|
|
print "[verify] #{file} exists "
|
|
|
|
if pathname.exist?
|
|
|
|
puts "[OK]"
|
|
|
|
else
|
|
|
|
$stderr.puts "[FAIL]"
|
|
|
|
fail
|
|
|
|
end
|
|
|
|
|
|
|
|
print "[verify] #{file} is a UMD module "
|
2018-07-28 17:37:17 -04:00
|
|
|
if /module\.exports.*define\.amd/m.match?(pathname.read)
|
2017-03-11 12:33:11 -05:00
|
|
|
puts "[OK]"
|
|
|
|
else
|
|
|
|
$stderr.puts "[FAIL]"
|
|
|
|
fail
|
|
|
|
end
|
|
|
|
|
2017-05-15 10:17:28 -04:00
|
|
|
print "[verify] #{__dir__} can be required as a module "
|
|
|
|
_, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{__dir__}');")
|
2017-03-11 12:33:11 -05:00
|
|
|
if status.success?
|
|
|
|
puts "[OK]"
|
|
|
|
else
|
|
|
|
$stderr.puts "[FAIL]\n#{stderr}"
|
|
|
|
fail
|
|
|
|
end
|
|
|
|
end
|
2016-01-30 15:41:14 -05:00
|
|
|
end
|