【问题标题】:after upgrading RSpec to version 3 I can't run single spec file anymore将 RSpec 升级到版本 3 后,我无法再运行单个规范文件
【发布时间】:2017-07-20 00:19:20
【问题描述】:

我们正在将 rails 从 3.4 升级到 4.2。当我们将 rspec 升级到最新版本时,即使在强制 rspec 只运行一个规范之后,它也会运行大约 900 个测试,但我的文件只有两个上下文。我使用类似于此命令的内容:

rspec spec/myfile_spec.rb

有什么问题吗?我可以在 spec_helper 中修复它吗?我会

【问题讨论】:

  • 有错误吗?
  • 不,rspec 本身运行没有错误。但是,它不会运行例如 2 个测试,而是运行所有测试。
  • 你能发布你的spec_helper.rb吗?是否已将 .rspec 文件添加到您的项目中?

标签: ruby ruby-on-rails-3 rspec rspec-rails rspec3


【解决方案1】:

希望你没事! 您可以通过以下命令运行您想要的规范。

# Default: Run all spec files (i.e., those matching spec/**/*_spec.rb)
$ bundle exec rspec

# Run all spec files in a single directory (recursively)
$ bundle exec rspec spec/models

# Run a single spec file
$ bundle exec rspec spec/controllers/accounts_controller_spec.rb

# Run a single example from a spec file (by line number)
$ bundle exec rspec spec/controllers/accounts_controller_spec.rb:8

# See all options for running specs
$ bundle exec rspec --help

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    相关资源
    最近更新 更多