我无法让 rspec 自动测试正常工作? (红宝石,无导轨)

发布于 2024-12-20 05:54:41 字数 2016 浏览 1 评论 0原文

我有一个基本的 ruby​​ 项目:-

$ tree
.
├── Gemfile
├── lib
│   ├── checkout.rb
│   └── item.rb
├── README.md
└── test
    ├── checkout_spec.rb
    └── item_spec.rb

可以运行 rspec 测试:-

$ rspec test/*_spec.rb
....

Finished in 0.18797 seconds
4 examples, 0 failures

但是谁想每秒向上箭头并按 Enter 键,我想要自动测试...

但是当我运行它时,它找不到我的测试!

$ autotest -vw
No tests matched Gemfile
No tests matched README.md
No tests matched lib/checkout.rb
No tests matched lib/item.rb
No tests matched test/checkout_spec.rb
No tests matched test/item_spec.rb

然后我开始保存文件:-

{"lib/checkout.rb"=>2011-12-07 22:06:04 +0000}
No tests matched lib/checkout.rb
{"lib/checkout.rb"=>2011-12-07 22:06:04 +0000}
No tests matched lib/checkout.rb
{"test/.goutputstream-NQC45V"=>2011-12-07 22:06:20 +0000}
No tests matched test/.goutputstream-NQC45V
{"test/.goutputstream-NQC45V"=>2011-12-07 22:06:20 +0000}
No tests matched test/.goutputstream-NQC45V
{"lib/checkout.rb"=>2011-12-07 22:06:45 +0000}
No tests matched lib/checkout.rb
{"lib/checkout.rb"=>2011-12-07 22:06:45 +0000}
No tests matched lib/checkout.rb
<just sits here

我已经阅读了 .autotestspec_helper.rb,但似乎可以找到正确的搜索/页面?


编辑:锡人发现帮助和我的布局之间存在明显的不匹配。

但是将我的 test 更改为 tests 并没有帮助!:-

No tests matched tests/checkout_spec.rb
No tests matched tests/item_spec.rb
No tests matched tests/rule_parser_spec.rb
No tests matched tests/runner.rb
No tests matched tests/spec_helper.rb
{"lib/rule_parser.rb"=>2011-12-08 07:24:29 +0000}
No tests matched lib/rule_parser.rb
{"lib/rule_parser.rb"=>2011-12-08 07:24:29 +0000}
No tests matched lib/rule_parser.rb
{"tests/checkout_spec.rb"=>2011-12-08 07:24:35 +0000}
No tests matched tests/checkout_spec.rb
{"tests/checkout_spec.rb"=>2011-12-08 07:24:35 +0000}
No tests matched tests/checkout_spec.rb

I have a basic ruby project :-

$ tree
.
├── Gemfile
├── lib
│   ├── checkout.rb
│   └── item.rb
├── README.md
└── test
    ├── checkout_spec.rb
    └── item_spec.rb

Which can run the rspec tests :-

$ rspec test/*_spec.rb
....

Finished in 0.18797 seconds
4 examples, 0 failures

But who wants to up-arrow and press enter every sec, I wanted autotest...

But when I run it, it doesn't find my tests!

$ autotest -vw
No tests matched Gemfile
No tests matched README.md
No tests matched lib/checkout.rb
No tests matched lib/item.rb
No tests matched test/checkout_spec.rb
No tests matched test/item_spec.rb

Then I start saving files :-

{"lib/checkout.rb"=>2011-12-07 22:06:04 +0000}
No tests matched lib/checkout.rb
{"lib/checkout.rb"=>2011-12-07 22:06:04 +0000}
No tests matched lib/checkout.rb
{"test/.goutputstream-NQC45V"=>2011-12-07 22:06:20 +0000}
No tests matched test/.goutputstream-NQC45V
{"test/.goutputstream-NQC45V"=>2011-12-07 22:06:20 +0000}
No tests matched test/.goutputstream-NQC45V
{"lib/checkout.rb"=>2011-12-07 22:06:45 +0000}
No tests matched lib/checkout.rb
{"lib/checkout.rb"=>2011-12-07 22:06:45 +0000}
No tests matched lib/checkout.rb
<just sits here

I've read about .autotest and spec_helper.rb, but can seem to home in on the correct search/page?


Edit: A well spotted mismatch between the help and my layout spotted by the tin man.

But changing my test to tests did not help!:-

No tests matched tests/checkout_spec.rb
No tests matched tests/item_spec.rb
No tests matched tests/rule_parser_spec.rb
No tests matched tests/runner.rb
No tests matched tests/spec_helper.rb
{"lib/rule_parser.rb"=>2011-12-08 07:24:29 +0000}
No tests matched lib/rule_parser.rb
{"lib/rule_parser.rb"=>2011-12-08 07:24:29 +0000}
No tests matched lib/rule_parser.rb
{"tests/checkout_spec.rb"=>2011-12-08 07:24:35 +0000}
No tests matched tests/checkout_spec.rb
{"tests/checkout_spec.rb"=>2011-12-08 07:24:35 +0000}
No tests matched tests/checkout_spec.rb

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

生寂 2024-12-27 05:54:41

我认为你应该将其更改为规格。我不使用自动测试,但最新版本的 rspec 假设您的项目根目录中有一个规范目录。我想应该自动测试。

I think you should change it to spec. I don't use autotest but the latest versions of rspec assume you have a spec dir in to root of your project. So should autotest I guess.

对风讲故事 2024-12-27 05:54:41

我将目录更改为 spec

现在两者都工作了! :-

rspec
autotest

I changed the directory to spec!

Now both work! :-

rspec
autotest
鹿! 2024-12-27 05:54:41

将您的 test 目录更改为 tests。这应该会让自动测试更快乐。

来自autotest --help

它假设代码在 lib 中,测试在测试中。

Change your test directory to tests. That should make autotest happier.

From autotest --help:

It assumes the code is in lib, and tests are in tests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文