diff --git a/.gitignore b/.gitignore index 6a502e9..e135bfb 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ # Ignore all logfiles and tempfiles. /log/*.log /tmp +node_modules diff --git a/lib/tasks/karma.rake b/lib/tasks/karma.rake new file mode 100644 index 0000000..03bb940 --- /dev/null +++ b/lib/tasks/karma.rake @@ -0,0 +1,31 @@ +namespace :karma do + task :start => :environment do + with_tmp_config :start + end + + task :run => :environment do + with_tmp_config :start, "--single-run" + end + + private + + 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) + f.flush + + system "karma #{command} #{f.path} #{args}" + end + end + + def application_spec_files + sprockets = Rails.application.assets + sprockets.append_path Rails.root.join("spec/karma") + files = Rails.application.assets.find_asset("application_spec.js").to_a.map {|e| e.pathname.to_s } + end + + def unit_js(files) + unit_js = File.open('spec/karma/config/unit.js', 'r').read + unit_js.gsub "APPLICATION_SPEC", "\"#{files.join("\",\n\"")}\"" + end +end \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..10662b8 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "weroom-app", + "dependencies" : { + "karma": ">= 0.10.9", + "karma-jasmine": "0.1.5", + "karma-ng-scenario": "0.1.0", + "phantomjs": "1.9.7-1" + } +} \ No newline at end of file diff --git a/spec/javascripts/angular/controllers/.keep b/spec/javascripts/angular/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/javascripts/angular/directives/.keep b/spec/javascripts/angular/directives/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/javascripts/angular/filters/.keep b/spec/javascripts/angular/filters/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/javascripts/angular/services/.keep b/spec/javascripts/angular/services/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/karma/application_spec.js b/spec/karma/application_spec.js new file mode 100644 index 0000000..92a7926 --- /dev/null +++ b/spec/karma/application_spec.js @@ -0,0 +1,3 @@ +//= require angular +//= require angular-mocks +//= require application \ No newline at end of file diff --git a/spec/karma/config/unit.js b/spec/karma/config/unit.js new file mode 100644 index 0000000..ca6ac58 --- /dev/null +++ b/spec/karma/config/unit.js @@ -0,0 +1,75 @@ +// Karma configuration +// Generated on Mon Feb 03 2014 16:16:15 GMT+0100 (CET) + +module.exports = function(config) { + config.set({ + + // base path, based on tmp/ folder + basePath: '..', + + + // frameworks to use + frameworks: ['jasmine', 'ng-scenario'], + + + // list of files / patterns to load in the browser + files: [ + "/usr/local/var/rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.2.1/lib/assets/javascripts/turbolinks.*", + 'app/assets/javascripts/angular/*/*.{coffee,js}', + 'spec/javascripts/**/*_spec.{coffee,js}' + ], + + // list of files to exclude + exclude: [ + + ], + + + // test results reporter to use + // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // Start these browsers, currently available: + // - Chrome + // - ChromeCanary + // - Firefox + // - Opera (has to be installed with `npm install karma-opera-launcher`) + // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`) + // - PhantomJS + // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`) + browsers: ['PhantomJS'], + + + // If browser does not capture in given timeout [ms], kill it + captureTimeout: 60000, + + + // Continuous Integration mode + // if true, it capture browsers, run tests and exit + singleRun: false, + + // Preprocessors + preprocessors: { + '/**/*.coffee':'coffee' + } + + }); +};