Sha256: 5431ddc39c2f202bfd93330305aa9b777c04b2e7e3268944a6a010aa49c61955

Contents?: true

Size: 1.25 KB

Versions: 19

Compression:

Stored size: 1.25 KB

Contents

TEST_CHANGES_SINCE = Time.now - 600

namespace :test do
  namespace :recent do
    desc "Open recently modified files into browser"
    task :javascript do
      require 'rubygems'
      gem 'activesupport'
      require 'active_support'

      since = TEST_CHANGES_SINCE
      touched = FileList[
        'test/unit/*_test.html', 
        'src/*.js'].select { |path| File.mtime(path) > since }
      next if touched.blank?
      
      gem 'newjs'
      require 'newjs'
      require 'newjs/autotest'
      
      touched.each do |file|
        if file =~ /\/([^\/]+)\.js$/
          file = "test/unit/#{$1}_test.html"
        end
        file = "#{APP_ROOT}/#{file}"
        unless File.exists?(file)
          # puts "Notice: Test file does not exist: #{file}"
          next
        end
        puts "Launching test: #{file}"
        browsers = JavascriptTestAutotest::Config.get :browsers
        if browsers.blank?
          puts "WARNING: No browsers setup in config/javascript_test_autotest.yml"
          next
        end
        browsers.each_pair do |name, path|
          browser = JavascriptTestAutotest::Browser.browser(name, path)
          browser.setup
          browser.visit(file)
          browser.teardown          
        end
      end
    end
  end
end

Version data entries

19 entries across 15 versions & 1 rubygems

Version Path
newjs-1.7.4 vendor/jshoulda/tasks/javascript_test_autotest_tasks.rake
newjs-1.7.4 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.3.1 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.3.2 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.3.4 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.3.5 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.3.3 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.3.6 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.4.0 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.4.1 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.5.0 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.5.1 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.7.0 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.7.0 vendor/jshoulda/tasks/javascript_test_autotest_tasks.rake
newjs-1.7.1 vendor/jshoulda/tasks/javascript_test_autotest_tasks.rake
newjs-1.7.1 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.3.7 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.7.2 app_generators/newjs/templates/tasks/javascript_test_autotest_tasks.rake
newjs-1.7.2 vendor/jshoulda/tasks/javascript_test_autotest_tasks.rake