From bf6a147c85752fade6cae27b7dc3e3a3cdf07e2e Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Thu, 15 Nov 2012 15:14:33 -0500 Subject: [PATCH] Modify rake file to read in spec and src files correctly and also add in the lms helper file for stubRequests, etc. --- .../lib/xmodule/jasmine_test_runner.html.erb | 4 ++-- rakefile | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/jasmine_test_runner.html.erb b/common/lib/xmodule/jasmine_test_runner.html.erb index 01d55e50a9..edf4b43c2c 100644 --- a/common/lib/xmodule/jasmine_test_runner.html.erb +++ b/common/lib/xmodule/jasmine_test_runner.html.erb @@ -25,9 +25,9 @@ <% end %> - + <% for src in js_specs %> - + <% end %> diff --git a/rakefile b/rakefile index a9bcdd8d79..d2249d2ed8 100644 --- a/rakefile +++ b/rakefile @@ -89,8 +89,22 @@ def template_jasmine_runner(lib) phantom_jasmine_path = File.expand_path("common/test/phantom-jasmine") common_js_root = File.expand_path("common/static/js") common_coffee_root = File.expand_path("common/static/coffee/src") - js_specs = Dir["#{lib}/**/js/spec/**/*.js"].sort_by {|p| [p.split('/').length, p]} .map {|f| File.expand_path(f)} - js_source = Dir["#{lib}/**/*.js"].sort_by {|p| [p.split('/').length, p]} .map {|f| File.expand_path(f)} - js_specs + + # Get arrays of spec and source files, ordered by how deep they are nested below the library + # (and then alphabetically) and expanded from a relative to an absolute path + spec_glob = File.join("#{lib}", "**", "spec", "**", "*.js") + src_glob = File.join("#{lib}", "**", "src", "**", "*.js") + js_specs = Dir[spec_glob].sort_by {|p| [p.split('/').length, p]} .map {|f| File.expand_path(f)} + js_source = Dir[src_glob].sort_by {|p| [p.split('/').length, p]} .map {|f| File.expand_path(f)} + + # helper file + helper_coffee = "#{REPO_ROOT}/lms/static/coffee/spec/helper.coffee" + if File.exists?(helper_coffee) + sh("coffee -c #{helper_coffee}") + # Add the compiled helper to the beginning of the specs array + js_specs.unshift("#{REPO_ROOT}/lms/static/coffee/spec/helper.js") + end + template = ERB.new(File.read("#{lib}/jasmine_test_runner.html.erb")) template_output = "#{lib}/jasmine_test_runner.html" File.open(template_output, 'w') do |f|