How to Mock a Custom Type in Rspec-Puppet

Deadly 提交于 2019-12-03 22:17:01

A good place to go looking for examples on mocking is the collection of Puppet's own unit tests.

I'm not sure if there are an specialties that needs to be considered, but within Puppet's spec test, the mocking works like this:

let(:type) { Puppet::Type.type(:custom_file_line) }
it "should do whatever"
  type.stubs(:retrieve).returns <value>
  # perhaps also needed
  Puppet::Type.stubs(:type).with(:custom_file_line).returns(type)

From what I understand, this is moccha style mocking. In plain rspec, mocking/stubbing is a bit more involved, which may be necessary with rspec-puppet.

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