Rails 4 + Jasmine: Jasmine找不到我的规范文件



我正在Rails 4项目上工作,并试图编写Jasmine测试,但看起来Jasmine没有检测到我的任何文件。

我的spec/javascripts文件夹是这样的:

./
├── e2e
│   └── products_scenarios.js
├── foo_spec.js
└── support
    └── jasmine.yml

和茉莉。yml:

# # path to parent directory of src_files
# # relative path from Rails.root
# # defaults to app/assets/javascripts
# src_dir: "app/assets/javascripts"
#
# # path to parent directory of css_files
# # relative path from Rails.root
# # defaults to app/assets/stylesheets
# css_dir: "app/assets/stylesheets"
#
# # list of file expressions to include as source files
# # relative path from src_dir
# src_files:
#  - "application.{js.coffee,js,coffee}"
#
# # list of file expressions to include as css files
# # relative path from css_dir
# css_files:
#
# # path to parent directory of spec_files
# # relative path from Rails.root
# # defaults to spec/javascripts
spec_dir: spec/javascripts
#
# # list of file expressions to include as helpers into spec runner
# # relative path from spec_dir
# helpers:
#   - "helpers/**/*.{js.coffee,js,coffee}"
# list of file expressions to include as specs into spec runner
# relative path from spec_dir
spec_files:
  - "**/*[Ss]pec.{js.coffee,js,coffee}"
# path to directory of temporary files
# (spec runner and asset cache)
# defaults to tmp/jasmine
# tmp_dir: "tmp/jasmine"

和foo_spec.js内部:

describe('Foo', function() {
  it("does something", function() {
    expect(1+1).toBe(2);
  });
});
describe('ProductsCtrl', function() {
  beforeEach(module('ilook'));
  it('sets title to zzzzz', inject(function($controller) {
    var scope = {},
        ctrl = $controller('ProductsCtrl', { $scope: scope });
    expect(scope.title).toBe("My zzzz");
  }));
});

但是,当我运行测试时:

Nets-Mac-Pro:mysite emai$ be rake spec:javascript
Running `"/Users/emai/.phantomjs/1.9.7/darwin/bin/phantomjs" "/Users/emai/.rvm/gems/ruby-2.0.0-p247@mysite/gems/jasmine-rails-0.9.1/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/Users/emai/Documents/mysite/tmp/jasmine/runner.html?spec="`
Running: /Users/emai/Documents/mysite/tmp/jasmine/runner.html?spec=
Starting...
Finished
-----------------
0 specs, 0 failures in 0.002s.

上面说我没有规格。这是怎么呢我保存了我所有的文件

添加此文件

# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
#   - lib/source1.js
#   - lib/source2.js
#   - dist/**/*.js
#
src_files:
  - assets/application.js
  - assets/jasmine-jquery.js
# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# stylesheets:
#   - css/style.css
#   - stylesheets/*.css
#
stylesheets:
  - stylesheets/**/*.css
# helpers
#
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
# Default: ["helpers/**/*.js"]
#
# EXAMPLE:
#
# helpers:
#   - helpers/**/*.js
#
helpers:
  - helpers/**/*.js
# spec_files
#
# Return an array of filepaths relative to spec_dir to include.
# Default: ["**/*[sS]pec.js"]
#
# EXAMPLE:
#
# spec_files:
#   - **/*[sS]pec.js
#
spec_files:
  - '**/*[sS]pec.js'
# src_dir
#
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
# Default: project root
#
# EXAMPLE:
#
# src_dir: public
#
src_dir:
# spec_dir
#
# Spec directory path. Your spec_files must be returned relative to this path.
# Default: spec/javascripts
#
# EXAMPLE:
#
# spec_dir: spec/javascripts
#
spec_dir: spec/javascripts

也试着运行下面的命令来运行jasmine

 rake jasmine

显示端口号。所以在端口号

上运行服务器

最新更新