Skip to content

Commit d2ae297

Browse files
authored
Merge pull request #8879 from joshcooper/rspec_ruby3_11456
(PUP-11456) Avoid ruby kwarg and hash confusion with doubles
2 parents a51b926 + 3fab06e commit d2ae297

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spec/unit/confiner_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
require 'puppet/confiner'
44

55
describe Puppet::Confiner do
6+
let(:coll) { Puppet::ConfineCollection.new('') }
7+
68
before do
79
@object = Object.new
810
@object.extend(Puppet::Confiner)
@@ -21,7 +23,6 @@
2123
end
2224

2325
it "should delegate its confine method to its confine collection" do
24-
coll = double('collection')
2526
allow(@object).to receive(:confine_collection).and_return(coll)
2627
expect(coll).to receive(:confine).with(:foo => :bar, :bee => :baz)
2728
@object.confine(:foo => :bar, :bee => :baz)
@@ -39,22 +40,21 @@
3940

4041
describe "when testing suitability" do
4142
before do
42-
@coll = double('collection')
43-
allow(@object).to receive(:confine_collection).and_return(@coll)
43+
allow(@object).to receive(:confine_collection).and_return(coll)
4444
end
4545

4646
it "should return true if the confine collection is valid" do
47-
expect(@coll).to receive(:valid?).and_return(true)
47+
expect(coll).to receive(:valid?).and_return(true)
4848
expect(@object).to be_suitable
4949
end
5050

5151
it "should return false if the confine collection is invalid" do
52-
expect(@coll).to receive(:valid?).and_return(false)
52+
expect(coll).to receive(:valid?).and_return(false)
5353
expect(@object).not_to be_suitable
5454
end
5555

5656
it "should return the summary of the confine collection if a long result is asked for" do
57-
expect(@coll).to receive(:summary).and_return("myresult")
57+
expect(coll).to receive(:summary).and_return("myresult")
5858
expect(@object.suitable?(false)).to eq("myresult")
5959
end
6060
end

0 commit comments

Comments
 (0)