Skip to content

Commit 95291a9

Browse files
authored
Merge pull request #8942 from joshcooper/rspec-mocks
(maint) Expect `with` hash arguments instead of kwargs
2 parents eb498be + 1480189 commit 95291a9

File tree

15 files changed

+41
-46
lines changed

15 files changed

+41
-46
lines changed

spec/unit/agent_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def controlled_run(&block)
173173
client = AgentTestClient.new
174174
expect(AgentTestClient).to receive(:new).and_return(client)
175175

176-
expect(client).to receive(:run).with(:pluginsync => true, :other => :options)
176+
expect(client).to receive(:run).with({:pluginsync => true, :other => :options})
177177
@agent.run(:other => :options)
178178
end
179179

spec/unit/confiner_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
it "should delegate its confine method to its confine collection" do
2626
allow(@object).to receive(:confine_collection).and_return(coll)
27-
expect(coll).to receive(:confine).with(:foo => :bar, :bee => :baz)
27+
expect(coll).to receive(:confine).with({:foo => :bar, :bee => :baz})
2828
@object.confine(:foo => :bar, :bee => :baz)
2929
end
3030

spec/unit/indirector/indirection_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
it "should create a request object with the appropriate method name and all of the passed arguments" do
77
request = Puppet::Indirector::Request.new(:indirection, :find, "me", nil)
88

9-
expect(@indirection).to receive(:request).with(@method, "mystuff", nil, :one => :two).and_return(request)
9+
expect(@indirection).to receive(:request).with(@method, "mystuff", nil, {:one => :two}).and_return(request)
1010

1111
allow(@terminus).to receive(@method)
1212

spec/unit/module_tool/tar/mini_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def unpacks_the_entry(type, name, mode = 0100)
8282
expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
8383
expect(minitar).to receive(:find_valid_files).with(reader).and_return([name])
8484
entry = MockFileStatEntry.new(mode)
85-
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, [name], :fsync => false).
85+
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, [name], {:fsync => false}).
8686
and_yield(type, name, {:entry => entry})
8787
entry
8888
end

spec/unit/provider/ldap_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
it "should create a provider with the results of the find" do
8686
expect(@manager).to receive(:find).with("one").and_return("one" => "two")
8787

88-
expect(@class).to receive(:new).with("one" => "two", :ensure => :present).and_return("myprovider")
88+
expect(@class).to receive(:new).with({"one" => "two", :ensure => :present}).and_return("myprovider")
8989

9090
expect(@resource).to receive(:provider=).with("myprovider")
9191

@@ -95,7 +95,7 @@
9595
it "should set :ensure to :present in the returned values" do
9696
expect(@manager).to receive(:find).with("one").and_return("one" => "two")
9797

98-
expect(@class).to receive(:new).with("one" => "two", :ensure => :present).and_return("myprovider")
98+
expect(@class).to receive(:new).with({"one" => "two", :ensure => :present}).and_return("myprovider")
9999

100100
expect(@resource).to receive(:provider=).with("myprovider")
101101

spec/unit/provider/package/dpkg_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
expect(Puppet::Util::Execution).to receive(:execpipe).with(execpipe_args).and_yield(bash_installed_io)
3333

3434
installed = double('bash')
35-
expect(described_class).to receive(:new).with(:ensure => "4.2-5ubuntu3", :error => "ok", :desired => "install", :name => "bash", :mark => :none, :status => "installed", :provider => :dpkg).and_return(installed)
35+
expect(described_class).to receive(:new).with({:ensure => "4.2-5ubuntu3", :error => "ok", :desired => "install", :name => "bash", :mark => :none, :status => "installed", :provider => :dpkg}).and_return(installed)
3636

3737
expect(described_class.instances).to eq([installed])
3838
end
@@ -41,9 +41,9 @@
4141
expect(Puppet::Util::Execution).to receive(:execpipe).with(execpipe_args).and_yield(all_installed_io)
4242

4343
bash = double('bash')
44-
expect(described_class).to receive(:new).with(:ensure => "4.2-5ubuntu3", :error => "ok", :desired => "install", :name => "bash", :mark => :none, :status => "installed", :provider => :dpkg).and_return(bash)
44+
expect(described_class).to receive(:new).with({:ensure => "4.2-5ubuntu3", :error => "ok", :desired => "install", :name => "bash", :mark => :none, :status => "installed", :provider => :dpkg}).and_return(bash)
4545
vim = double('vim')
46-
expect(described_class).to receive(:new).with(:ensure => "2:7.3.547-6ubuntu5", :error => "ok", :desired => "install", :name => "vim", :mark => :none, :status => "installed", :provider => :dpkg).and_return(vim)
46+
expect(described_class).to receive(:new).with({:ensure => "2:7.3.547-6ubuntu5", :error => "ok", :desired => "install", :name => "vim", :mark => :none, :status => "installed", :provider => :dpkg}).and_return(vim)
4747

4848
expect(described_class.instances).to eq([bash, vim])
4949
end

spec/unit/provider/package/pkgutil_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
expect(described_class).to receive(:pkguti).with(['-c']).and_return(fake_data)
196196

197197
testpkg = double('pkg1')
198-
expect(described_class).to receive(:new).with(:ensure => "1.4.5,REV=2007.11.18", :name => "TESTpkg", :provider => :pkgutil).and_return(testpkg)
198+
expect(described_class).to receive(:new).with({:ensure => "1.4.5,REV=2007.11.18", :name => "TESTpkg", :provider => :pkgutil}).and_return(testpkg)
199199
expect(described_class.instances).to eq([testpkg])
200200
end
201201

@@ -207,10 +207,10 @@
207207
expect(described_class).to receive(:pkguti).with(['-c']).and_return(fake_data)
208208

209209
testpkg = double('pkg1')
210-
expect(described_class).to receive(:new).with(:ensure => "1.4.5,REV=2007.11.18", :name => "TESTpkg", :provider => :pkgutil).and_return(testpkg)
210+
expect(described_class).to receive(:new).with({:ensure => "1.4.5,REV=2007.11.18", :name => "TESTpkg", :provider => :pkgutil}).and_return(testpkg)
211211

212212
aliaspkg = double('pkg2')
213-
expect(described_class).to receive(:new).with(:ensure => "1.4.5,REV=2007.11.18", :name => "mypkg", :provider => :pkgutil).and_return(aliaspkg)
213+
expect(described_class).to receive(:new).with({:ensure => "1.4.5,REV=2007.11.18", :name => "mypkg", :provider => :pkgutil}).and_return(aliaspkg)
214214

215215
expect(described_class.instances).to eq([testpkg,aliaspkg])
216216
end
@@ -223,7 +223,7 @@
223223
expect(described_class).to receive(:pkguti).with(['-c']).and_return(fake_data)
224224

225225
testpkg = double('pkg1')
226-
expect(described_class).to receive(:new).with(:ensure => "1.4.5,REV=2007.11.18", :name => "TESTpkg", :provider => :pkgutil).and_return(testpkg)
226+
expect(described_class).to receive(:new).with({:ensure => "1.4.5,REV=2007.11.18", :name => "TESTpkg", :provider => :pkgutil}).and_return(testpkg)
227227

228228
expect(described_class.instances).to eq([testpkg])
229229
end

spec/unit/provider/parsedfile_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
{:name => 'target3_record2'}
6060
])
6161
expect(Puppet).to receive(:err).with('Could not prefetch parsedfile_type provider \'parsedfile_provider\' target \'/two\': some error. Treating as empty')
62-
expect(provider).to receive(:new).with(:name => 'target1_record1', :on_disk => true, :target => '/one', :ensure => :present).and_return('r1')
63-
expect(provider).to receive(:new).with(:name => 'target1_record2', :on_disk => true, :target => '/one', :ensure => :present).and_return('r2')
64-
expect(provider).to receive(:new).with(:name => 'target3_record1', :on_disk => true, :target => '/three', :ensure => :present).and_return('r3')
65-
expect(provider).to receive(:new).with(:name => 'target3_record2', :on_disk => true, :target => '/three', :ensure => :present).and_return('r4')
62+
expect(provider).to receive(:new).with({:name => 'target1_record1', :on_disk => true, :target => '/one', :ensure => :present}).and_return('r1')
63+
expect(provider).to receive(:new).with({:name => 'target1_record2', :on_disk => true, :target => '/one', :ensure => :present}).and_return('r2')
64+
expect(provider).to receive(:new).with({:name => 'target3_record1', :on_disk => true, :target => '/three', :ensure => :present}).and_return('r3')
65+
expect(provider).to receive(:new).with({:name => 'target3_record2', :on_disk => true, :target => '/three', :ensure => :present}).and_return('r4')
6666

6767
expect(provider.instances).to eq(%w{r1 r2 r3 r4})
6868
end

spec/unit/transaction/event_manager_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@
191191

192192
allow(@resource).to receive(:callback1)
193193

194-
expect(@resource).to receive(:event).with(:message => "Triggered 'callback1' from 1 event", :status => 'success', :name => 'callback1')
195-
expect(@resource).to receive(:event).with(:name => :restarted, :status => "success").and_return("myevent")
194+
expect(@resource).to receive(:event).with({:message => "Triggered 'callback1' from 1 event", :status => 'success', :name => 'callback1'})
195+
expect(@resource).to receive(:event).with({:name => :restarted, :status => "success"}).and_return("myevent")
196196
expect(@manager).to receive(:queue_events).with(@resource, ["myevent"])
197197

198198
@manager.process_events(@resource)

spec/unit/transaction_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def generate
570570
end
571571

572572
it "should match resources by name, not title" do
573-
expect(resource.provider.class).to receive(:prefetch).with("bar" => resource)
573+
expect(resource.provider.class).to receive(:prefetch).with({"bar" => resource})
574574

575575
transaction.prefetch_if_necessary(resource)
576576
end
@@ -598,7 +598,7 @@ def generate
598598
catalog.add_resource other
599599

600600
allow(resource.class).to receive(:defaultprovider).and_return(resource.provider.class)
601-
expect(resource.provider.class).to receive(:prefetch).with('bar' => resource, 'other' => other)
601+
expect(resource.provider.class).to receive(:prefetch).with({'bar' => resource, 'other' => other})
602602

603603
transaction.prefetch_if_necessary(resource)
604604
end

0 commit comments

Comments
 (0)