diff options
Diffstat (limited to 'actionview/Rakefile')
-rw-r--r-- | actionview/Rakefile | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/actionview/Rakefile b/actionview/Rakefile index 00ab92129d..de588ad25c 100644 --- a/actionview/Rakefile +++ b/actionview/Rakefile @@ -1,10 +1,13 @@ require "rake/testtask" require "fileutils" +require "open3" + +dir = File.dirname(__FILE__) desc "Default Task" task default: :test -task package: "assets:compile" +task package: %w( assets:compile assets:verify ) # Run the unit tests @@ -84,8 +87,46 @@ namespace :assets do desc "Compile Action View assets" task :compile do require "blade" + require "sprockets" + require "sprockets/export" Blade.build end + + desc "Verify compiled Action View assets" + task :verify do + file = "lib/assets/compiled/rails-ujs.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 " + js = <<-JS + window = { Event: class {} } + class Element {} + require('#{dir}') + JS + stdout, stderr, status = Open3.capture3("node", "--print", js) + if status.success? + puts "[OK]" + else + $stderr.puts "[FAIL]\n#{stderr}" + fail + end + end end task :lines do |