From 77fbea1b18405e3620d6cc276c65ae7575c41de9 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 2 May 2011 17:53:57 -0400 Subject: [PATCH] be able to have multiple extensions counted as 'javascript' --- lib/autotest/jasmine_mixin.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/autotest/jasmine_mixin.rb b/lib/autotest/jasmine_mixin.rb index 16440df..f85b119 100644 --- a/lib/autotest/jasmine_mixin.rb +++ b/lib/autotest/jasmine_mixin.rb @@ -1,6 +1,8 @@ module JasmineMixin JASMINE_PROGRAM = File.expand_path('../../../bin/jasmine-headless-webkit', __FILE__) + JAVASCRIPT_EXTENSIONS = %w{js} + def self.included(klass) klass::ALL_HOOKS << [ :run_jasmine, :ran_jasmine ] end @@ -57,13 +59,15 @@ module JasmineMixin def find_files Hash[super.find_all { |file, mtime| + is_js = (file[%r{\.(#{JAVASCRIPT_EXTENSIONS.join('|')})$}] != nil) + case self.is_jasmine_running when :all true when :no - file[%r{\.js$}] == nil + !is_js when :yes - file[%r{\.js$}] != nil + is_js end }] end @@ -81,4 +85,8 @@ module JasmineMixin [ "spec/javascripts/#{m[1]}_spec.js" ] } end + + def add_javascript_extensions(*extensions) + self.class::JAVASCRIPT_EXTENSIONS << extensions + end end