Chefspec, stubbing a resource that is being generated multiple times


#1

Hey Everyone,
Say I am doing something like this:

%w(pkg1 pkg2 pkg3).each { |rpm|
execute ‘Remove these RPMs but not their deps’ do
command "rpm -e -v --nodeps #{rpm}"
only_if "rpm -q #{rpm}"
end
}

Do I have to stub out every possible execute statement this would produce?

-William


#2

command stubs in chefspec are not resource specific iirc. But in this case
you have three different commands, so you have to stub all three.

On Mon, Apr 20, 2015 at 2:39 PM, William Jimenez wjimenez5271@gmail.com
wrote:

Hey Everyone,
Say I am doing something like this:

%w(pkg1 pkg2 pkg3).each { |rpm|
execute ‘Remove these RPMs but not their deps’ do
command "rpm -e -v --nodeps #{rpm}"
only_if "rpm -q #{rpm}"
end
}

Do I have to stub out every possible execute statement this would produce?

-William