将 Rspec 测试翻译为 Shoulda

发布于 2024-09-09 06:35:05 字数 300 浏览 0 评论 0原文

我有一个预先编写的 Rails 应用程序,用于处理基于订阅的付款,目前 Rspec 测试套件已涵盖该应用程序。我正在尝试将其合并到使用 Shoulda 测试套件覆盖的 Rails 应用程序中。

我真的不想手动将所有测试重写为 Shoulda 兼容的匹配器,所以我想知道是否有更简单的方法来做到这一点。我对这两个测试框架都不是很有经验,所以我正在尝试制定一个最佳开始方式的计划。

我听说 Shoulda 有一些 Rspec 兼容的匹配器,但是它们涵盖了每个 rspec 匹配器吗?真的有那么容易吗?

有没有人有过这样做的经验,这有多大问题?

I have a pre-written Rails app for handling subscription based payments that is currently covered with an Rspec test suite. I'm trying to merge it into a Rails app that is covered using the Shoulda test suite.

I'd really hate to have to rewrite all the tests into Shoulda compatible matchers manually, so I was wondering if there may be an easier way to do this. I'm not very experienced with either testing framework, so I'm trying to make a plan on the best way to start.

I've heard that Shoulda has some Rspec compatible matchers, but do they cover every rspec matcher? Could it really be as easy as that?

Has anyone had any experience doing something like this, and how much of a problem was it?

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

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

发布评论

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

评论(1

眼眸里的快感 2024-09-16 06:35:05

我想你去 RSpec 可能会有更好的运气。据我所知,rSpec 将运行 Test::Unit(因此应该运行宏)以及 Spec 文件。如果您将所有内容都移至 Shoulda,那么我认为您最终会重写许多测试。

http://blog.davidchelimsky.net/2009 /02/02/rspec-works-with-test-unit/

所以这应该只是将测试转移到规范的问题。

我从未尝试过在 rspec 中运行 Shoulda 宏,仅尝试运行 Shoulda 匹配器。但我不认为这会是一个大问题。

I think you might have better luck going to RSpec. To the best of my knowledge, rSpec will run both Test::Unit (and therefore shoulda macros) along with Spec files. If you were to move everything to shoulda, then I think you would end up rewriting many of the tests.

http://blog.davidchelimsky.net/2009/02/02/rspec-works-with-test-unit/

So it should just be a matter of moving your tests over to specs.

I have never tried to run shoulda macros within rspec, only the shoulda matchers. I don't believe it would be that much of an issue though.

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