Migrating from RSpec to Minitest::Spec?

隐身守侯 提交于 2019-12-14 00:46:11

问题


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.


回答1:


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:

  • 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.



来源:https://stackoverflow.com/questions/8423227/migrating-from-rspec-to-minitestspec

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!