diff --git a/lib/tasks/karma.rake b/lib/tasks/karma.rake index 3755dacc63..7cc245cfa4 100644 --- a/lib/tasks/karma.rake +++ b/lib/tasks/karma.rake @@ -1,28 +1,22 @@ +ENV["RAILS_ENV"] ||= 'test' + namespace :karma do - task :start => :environment do |task| - continue_only_in_test_env task + task :start => :environment do |_task| with_tmp_config :start end - task :run => :environment do |task| - continue_only_in_test_env task + task :run => :environment do |_task| with_tmp_config :start, "--single-run" end private - def continue_only_in_test_env task - if Rails.env != 'test' - raise "Task must be called in test environment:\n bundle exec rake #{task.name} RAILS_ENV=test" - end - end - def with_tmp_config(command, args = nil) Tempfile.open('karma_unit.js', Rails.root.join('tmp') ) do |f| f.write unit_js(application_spec_files << i18n_file) f.flush trap('SIGINT') { puts "Killing Karma"; exit } - exec "karma #{command} #{f.path} #{args}" + exec "node_modules/.bin/karma #{command} #{f.path} #{args}" end end