我刚刚开始使用rails-assets.org来服务我的javascript文件,除了现在的karma单元测试不起作用外,这是很好的工作方式。
这是我的业力配置文件,问题是我已经删除了所有的angular-1.2.22目录并通过gem访问了它。
// Karma configuration
// Generated on Thu Aug 15 2013 13:47:52 GMT+1000 (EST)
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
// libraries
'app/assets/javascripts/keymaster/keymaster.js',
'vendor/assets/javascripts/jquery.js',
'vendor/assets/javascripts/angular-1.2.22/angular.min.js',
'vendor/assets/javascripts/angular-1.2.22/angular-mocks.js',
'vendor/assets/javascripts/angular-1.2.22/angular-resource.js',
'vendor/assets/javascripts/ng-table-master/ng-table.min.js',
'vendor/assets/javascripts/ui-utils/modules/keypress/keypress.js',
'vendor/assets/javascripts/ui-utils/modules/mask/mask.js',
'vendor/assets/javascripts/angularjs-country-select-master/angular.country-select.js',
'vendor/assets/javascripts/*.js',
// application code
'app/assets/javascripts/*.js',
'app/assets/javascripts/app/main.js.coffee',
'app/assets/javascripts/config/*.js.coffee',
'app/assets/javascripts/app/services/*.js.coffee',
'app/assets/javascripts/app/resources/*.js.coffee',
'app/assets/javascripts/app/controllers/*.js.coffee',
'app/assets/javascripts/app/directives/*.js.coffee',
// tests
'spec/javascripts/unit/spec.js.coffee',
'spec/javascripts/unit/*_spec.js.coffee'
],
// 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,
// 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
});
};我现在就是这样安装我的AngularJS javascript文件的
gem 'rails-assets-angular', '1.2.2' # Upgrading will change the order for ng-table for some reason.
gem 'rails-assets-angular-sanitize', '1.2.2'
gem 'rails-assets-angular-resource', '1.2.2'
gem 'rails-assets-angular-mocks', '1.2.2'
gem 'rails-assets-angular-ui-router', '~> 0.0.1'
gem 'rails-assets-map7--angularjs-country-select', '~> 0.0.1'
#gem 'rails-assets-angular-flash' # May not have my additions, need to check
gem 'rails-assets-ng-table', '~> 0.3.0'
gem 'rails-assets-lodash'
gem 'rails-assets-textAngular', '~> 1.2.2'
gem 'rails-assets-font-awesome'这不会放置一个我可以直接链接到的javascript文件。我如何配置业力,以加载角钢时,角是通过轨道本身?
更新
我已经找到了这个教程,它应该修复这个问题,但是它不能检测coffeescript并抱怨每个文件。
http://sebastien.saunier.me/blog/2014/02/04/angular--rails-with-no-fuss.html
现在,当我运行测试时,我得到了这个错误。
INFO [karma]: Karma v0.12.28 server started at http://localhost:9876/
INFO [Chrome 37.0.2062 (Linux)]: Connected on socket EuxRBXdMyCfQDtjzOqaH with id manual-1854
Chrome 37.0.2062 (Linux) ERROR
Uncaught SyntaxError: Unexpected token >
at /home/map7/pais/app/assets/javascripts/general.js.coffee:1general.js.coffee文件包含
$ ->
$("#from, #to").datepicker
dateFormat: "yy-mm-dd"发布于 2014-12-03 03:11:02
必须将以下内容添加到我的spec/karma/config/unit.js文件中
preprocessors: {
'../**/*.coffee': ['coffee']
},
coffeePreprocessor: {
// options passed to the coffee compiler
options: {
bare: true,
sourceMap: false
},
// transforming the filenames
transformPath: function(path) {
return path.replace(/\.coffee$/, '.js');
}
},将以下包添加到我的package.json中
"devDependencies": {
"karma-coffee-preprocessor": "^0.1.3"
}运行npm install
现在,在运行测试之前,它正在转换coffeescript。
https://stackoverflow.com/questions/27162927
复制相似问题