从RSpec迁移到Minitest :: Spec? [英] Migrating from RSpec to Minitest::Spec?

查看:81
本文介绍了从RSpec迁移到Minitest :: Spec?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在从RSpec 2迁移到MiniTest::Spec的策略或步骤集?我想看看如何在一个大型项目中执行此操作,但是我不确定从哪里开始.

Is there a strategy or set of steps to follow to migrate from RSpec 2 to MiniTest::Spec? I'd like to take a look at doing this for a large project but I'm not sure where to begin.

推荐答案

我已经很长时间没有使用MiniTest :: Spec了,我自己正在努力移植一些测试,但是这里有一些我已经注意到来自RSpec:

I haven't used MiniTest::Spec for that long, I'm working on porting over some of our tests myself, but here are the few things I've noticed coming from RSpec:

  • 匹配器当然是不同的-它是must/wont而不是should/should_not,并且谓词匹配器不见了,所以您不能说must_be_true/must_be_false之类
  • 也就是说,如果您已经编写了自定义RSpec匹配器,或者正在使用Shoulda-matchers或类似工具,那么由于minitest-matchers gem,您应该可以将它们与MiniTest一起使用.但是YMMV.
  • MiniTest :: Spec不提供context,因此您需要将其更改为describe或为其添加别名.
  • MiniTest :: Spec也未提供described_class.
  • 您也没有before :all.
  • subject必须手动设置(我认为,如果我错了,请纠正我).
  • The matchers are of course different -- it's must/wont instead of should/should_not, and predicate matchers are gone so you can't say must_be_true/must_be_false or the like.
  • That said, if you've written custom RSpec matchers, or are using shoulda-matchers or the like, you should be able to use them with MiniTest thanks to the minitest-matchers gem. But YMMV.
  • MiniTest::Spec doesn't provide context, so you'll need to either change this to describe or alias it.
  • MiniTest::Spec also doesn't provide described_class.
  • You also don't have before :all.
  • subject must be set manually (I think, someone correct me if I'm wrong).

因此,要回答您的问题,就移植现有的测试套件而言,恐怕您无法真正进行简单的查找和替换,您必须一次移植每个测试文件.显然,这意味着您必须确定付出的努力是否值得.

So to answer your question, in terms of porting an existing suite of tests, I'm afraid you can't really do a simple find and replace, you'll have to port over each test file one at a time. Obviously, this means you have to determine whether the effort is worth it.

这篇关于从RSpec迁移到Minitest :: Spec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆