Rails 4 + Jasmine:我如何在spec / javascripts / e2e /中要求spec文件?

时间:2014-07-24 18:45:39

标签: ruby-on-rails jasmine

我开始在我的项目中集成Angular,我想添加Jasmine测试。这是我的spec/javascripts文件夹树:

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

当我使用rake spec:javascript运行测试时,它只在foo_spec.js中运行测试。这是我的jasmine.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}"
#   - "**/e2e/*[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"

我如何要求e2e文件夹中的所有内容?或者更好的是,Rails项目中Jasmine测试的常用文件夹结构是什么?

1 个答案:

答案 0 :(得分:1)

spec_files的默认设置为:

spec_files:
- "**/*[Ss]pec.{js.coffee,js,coffee}"

products_scenarios.js重命名为products_scenarios_spec.js,并运行所需的规范。名称中包含specSpec的所有文件都将被jasmine视为规范。