Mocking custom types or providers

18 views
Skip to first unread message

Florian Thiel

unread,
May 18, 2015, 8:06:10 AM5/18/15
to puppet...@googlegroups.com
Hi,

I have a rspec-puppet test suite for a module that uses custom types whose provider requires a ruby gem. Is there an easy way to mock or stub the type?

I have the following snippet in my spec file (using mocha):

---
let(:type) { Puppet::Type.type(:foo_database_user) }
  before(:each) {
    Puppet::Type.stubs(:type).with(:foo_database).returns(type)
}
---

This mocks my custom type but breaks all built-in types (like groups). Using a Spy looks like the obvious solution but I could not find a way to do that with mocha.

Thanks in advance for any help,
Florian
Reply all
Reply to author
Forward
0 new messages