加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby – Minitest有RSpec的版本吗?

发布时间:2020-12-17 02:21:04 所属栏目:百科 来源:网络整理
导读:在RSpec我可以做mock_obj.should_receive(:方法).with(任何)…其中’任何’是任何变量. 我可以在Minitest做到这一点吗? 解决方法 Minitest,因为它包含在Ruby 1.9中,提供了MiniTest :: Spec,一种类似语境的RSpec语法.这不是RSpec. 从Github页面,这是Minites
在RSpec我可以做mock_obj.should_receive(:方法).with(任何)…其中’任何’是任何变量.

我可以在Minitest做到这一点吗?

解决方法

Minitest,因为它包含在Ruby 1.9中,提供了MiniTest :: Spec,一种类似语境的RSpec语法.这不是RSpec.

从Github页面,这是Minitest提供的

  • minitest/autorun – the easy and explicit way to run all your tests.
  • minitest/unit – a very fast,simple,and clean test system.
  • minitest/spec – a very fast,and clean spec system.
  • minitest/mock – a simple and clean mock/stub system.
  • minitest/benchmark – an awesome way to assert your algorithm’s performance.
  • minitest/pride – show your pride in testing!
  • Incredibly small and fast runner,but no bells and whistles.

要比mock_obj.should_receive(:method).with(任何东西)做同样的事情,你会写

要求’minitest / autorun’

describe YourClass do
  it 'should receive a call to method' do
    mock_obj = Minitest::Mock.new
    mock_obj.expect(:method,:your_return,[anything])
    # ...
    mock_obj.verify # verify that the expected call has been made
  end
end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读