在运行时递归地查找 RSpec 测试文件
我有一套 RSpec 测试,我想将其分组到以下层次结构中:
tests/
featA/
t1.rb
t2.rb
featB/
t3.rb
但是当我运行时
$ rspec tests
,我得到以下信息:
rspec tests
No examples were matched. Perhaps {:unless=>#<Proc:0x00007f318919cc08@/usr/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:51>, :if=>#<Proc:0x00007f318919cdc0@/usr/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:50>} is excluding everything?
Finished in 0.00003 seconds
0 examples, 0 failures
我觉得我要疯了,但似乎没有办法让 RSpec 递归地进行 glob用于测试文件?有这个功能吗?
编辑:
我有一个解决方法:
$ rspec `find tests -name "*.rb"`
但我怀疑我不应该这样做。我说得对吗?
I have a suite of RSpec tests I want to group under the following hierarchy:
tests/
featA/
t1.rb
t2.rb
featB/
t3.rb
but when I run
$ rspec tests
I get the following:
rspec tests
No examples were matched. Perhaps {:unless=>#<Proc:0x00007f318919cc08@/usr/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:51>, :if=>#<Proc:0x00007f318919cdc0@/usr/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:50>} is excluding everything?
Finished in 0.00003 seconds
0 examples, 0 failures
I feel like I'm going mad, but there doesn't seem to be a way to get RSpec to recursively glob for test files? Does this functionality exist?
EDIT:
I have a workaround by doing this:
$ rspec `find tests -name "*.rb"`
but I suspect I shouldn't have to. Am I right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你暴露了我的疏忽!在 rspec-1 中,您可以这样说:
但是 rspec-2 中缺少 --pattern 选项。我刚刚添加了它(开发中),它将包含在rspec-2.6.0 版本。
You've exposed an oversight on my part! In rspec-1, you could say this:
But the --pattern option is missing in rspec-2. I've just added it (in development) and it will be included in the rspec-2.6.0 release.
我通常通过
rake
管理在我的规范上运行 RSpec。我的 Rakefile 的相关部分如下所示:现在,rake spec 使用适当的选项运行 RSpec;您需要更改
t.pattern
以匹配您想要运行的规范。请务必查看 RSpec2网站了解更多信息。
I usually manage running RSpec on my specs via
rake
. The relevant portion of myRakefile
looks something like this:Now
rake spec
runs RSpec with the appropriate options; you'll need to changet.pattern
to match the specs you want to run.Be sure to check out the RSpec2 site for more information.