Skip to content

Commit 6ce24fb

Browse files
Stub the correct provider rather than the query
1 parent a101a2c commit 6ce24fb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spec/unit/provider/package/pkg_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ def self.it_should_respond_to(*actions)
286286

287287
it "should install specific version(2)" do
288288
resource[:ensure] = '0.0.8'
289-
expect(provider).to receive(:query).with(no_args).and_return({:ensure => '0.0.7,5.11-0.151006:20131230T130000Z'}).exactly(2).times
289+
expect(Puppet::Util::Execution).to receive(:execute)
290+
.with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true})
291+
.and_return(Puppet::Util::Execution::ProcessOutput.new('pkg://foo/[email protected],5.11-0.151006:20131230T13000 installed -----', 0)).exactly(2).times
290292
expect(Puppet::Util::Execution).to receive(:execute)
291293
.with(['/bin/pkg', 'update', *hash[:flags], '[email protected]'], {:failonfail => false, :combine => true})
292294
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
@@ -295,7 +297,9 @@ def self.it_should_respond_to(*actions)
295297

296298
it "should downgrade to specific version" do
297299
resource[:ensure] = '0.0.7'
298-
expect(provider).to receive(:query).with(no_args).and_return({:ensure => '0.0.8,5.11-0.151106:20131230T130000Z'}).exactly(2).times
300+
expect(Puppet::Util::Execution).to receive(:execute)
301+
.with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true})
302+
.and_return(Puppet::Util::Execution::ProcessOutput.new('pkg://foo/[email protected],5.11-0.151106:20131230T130000Z installed -----', 0)).exactly(2).times
299303
expect(Puppet::Util::Execution).to receive(:execute)
300304
.with(['/bin/pkg', 'update', *hash[:flags], '[email protected]'], {:failonfail => false, :combine => true})
301305
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))

0 commit comments

Comments
 (0)