[chef-dev] Mocking a Template Helper Method


Chronological Thread 
  • From: David Petzel < >
  • To: Chef Dev < >
  • Subject: [chef-dev] Mocking a Template Helper Method
  • Date: Fri, 19 Sep 2014 16:57:53 -0400

Hey Folks,
For some reason I can't figure out how to mock a method in chefspec that we are using in a Template Helper. We have the helper defined in a library module (1). I've done some mocks in the past for other library methods, however for some reason I can't seem to figure out the right way to get this to work for the template helper. Everything I've tried results in the mocked response not coming back.

Does anyone have an example or any docs on how I might pull this off? I'll refrain from posting all my failed versions, but this is the one I thought should work:

::Chef::Mixin::Template::TemplateContext.any_instance.stub(:my_method?).and_return(true) as well as 
allow(::Chef::Mixin::Template::TemplateContext).to receive(:my_method?).and_return(true)


Thanks



  • [chef-dev] Mocking a Template Helper Method, David Petzel, 09/19/2014

Archive powered by MHonArc 2.6.16.

§