【问题标题】:RSpec list all pending examplesRSpec 列出所有待处理的示例
【发布时间】:2011-11-02 15:05:52
【问题描述】:

我正在使用 Rspec 测试一个 Rails 应用程序。

有没有办法在不运行完整测试套件的情况下列出所有待处理的示例?

【问题讨论】:

标签: ruby-on-rails testing rspec rspec2


【解决方案1】:

运行 rspec 命令传递 --tag pending

例如: bundle exec rspec spec --tag pending

【讨论】:

  • 我喜欢这个答案,但它不会列出在 it 块内调用 pending 的规范。这不一定是缺点,但最好能意识到这一点。
  • bundle exec rspec spec 说我有 15 个待处理的示例,但添加 --tag pending 我只会得到 All examples were filtered out。无论这是做什么的,它都没有列出所有待处理的示例。
【解决方案2】:

对于 rspec 3.9,spec --dry-run 是我想要的。

me@host> bundle exec rspec -v
RSpec 3.9
  - rspec-core 3.9.2
  - rspec-expectations 3.9.1
  - rspec-mocks 3.9.1
  - rspec-rails 4.0.0.beta3
  - rspec-support 3.9.3

me@host> bundle exec rspec spec --dry-run
Randomized with seed 17761
...........................****..............................................................................................................................................................................*******................................................................................................................*****.*.*...................................................................................................................

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Klass completed
     # Not yet implemented
     # ./spec/models/klass.rb:79

  2) Klass completed with errors
     # Not yet implemented
     # ./spec/models/klass.rb:103

【讨论】:

  • 这是查找所有待定规范/示例的最全面方法。谢谢。
【解决方案3】:

当你有

it 'does something'

没有实际规范块的行,您可以通过编辑器的搜索功能和正则表达式的强大功能轻松找到它们:

^ *it{1} {1}('|").*{1}('|")\n

要测试正则表达式,您可以使用http://rubular.com/。它总是帮助我构建正则表达式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-13
    • 1970-01-01
    • 2018-10-07
    相关资源
    最近更新 更多