Skip to content

Commit b84fc77

Browse files
committed
(PUP-11634) Expect hash arguments instead of keywords
This is a continuation of commit 1480189. If a method is called with a hash, then the expectation must also be a hash, not keyword arguments.
1 parent 9524e47 commit b84fc77

29 files changed

+135
-135
lines changed

spec/unit/application/agent_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def run(options = {}); end
524524
end
525525

526526
it "should stop the daemon" do
527-
expect(@daemon).to receive(:stop).with(:exit => false)
527+
expect(@daemon).to receive(:stop).with({:exit => false})
528528

529529
expect { execute_agent }.to exit_with 0
530530
end

spec/unit/application/device_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@
535535
end
536536

537537
it "makes the Puppet::Pops::Loaders available" do
538-
expect(configurer).to receive(:run).with(:network_device => true, :pluginsync => false) do
538+
expect(configurer).to receive(:run).with({:network_device => true, :pluginsync => false}) do
539539
fail('Loaders not available') unless Puppet.lookup(:loaders) { nil }.is_a?(Puppet::Pops::Loaders)
540540
true
541541
end.and_return(6, 2)

spec/unit/application/resource_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
allow(@resource_app.command_line).to receive(:args).and_return(['type','name','param=temp'])
123123

124124
expect(Puppet::Resource.indirection).to receive(:save).with(@res, 'type/name').and_return([@res, @report])
125-
expect(Puppet::Resource).to receive(:new).with('type', 'name', :parameters => {'param' => 'temp'}).and_return(@res)
125+
expect(Puppet::Resource).to receive(:new).with('type', 'name', {:parameters => {'param' => 'temp'}}).and_return(@res)
126126

127127
@resource_app.main
128128
end

spec/unit/daemon_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def run_loop(jobs)
180180

181181
it "should shut down without exiting" do
182182
daemon.argv = %w{foo}
183-
expect(daemon).to receive(:stop).with(:exit => false)
183+
expect(daemon).to receive(:stop).with({:exit => false})
184184
daemon.reexec
185185
end
186186

spec/unit/file_bucket/dipper_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def make_tmp_file(contents)
322322
file = make_tmp_file(plaintext)
323323

324324
expect(Puppet::FileBucket::File.indirection).to receive(:head).with(
325-
%r{#{digest_algorithm}/#{checksum}}, :bucket_path => "/my/bucket"
325+
%r{#{digest_algorithm}/#{checksum}}, {:bucket_path => "/my/bucket"}
326326
).and_return(true)
327327
expect(Puppet::FileBucket::File.indirection).not_to receive(:save)
328328
expect(@dipper.backup(file)).to eq(checksum)

spec/unit/file_serving/fileset_spec.rb

+14-14
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ def mock_dir_structure(path, stat_method = :lstat)
153153
top_names = %w{one two .svn CVS}
154154
sub_names = %w{file1 file2 .svn CVS 0 false}
155155

156-
allow(Dir).to receive(:entries).with(path, encoding: Encoding::UTF_8).and_return(top_names)
156+
allow(Dir).to receive(:entries).with(path, {encoding: Encoding::UTF_8}).and_return(top_names)
157157
top_names.each do |subdir|
158158
@files << subdir # relative path
159159
subpath = File.join(path, subdir)
160160
allow(Puppet::FileSystem).to receive(stat_method).with(subpath).and_return(@dirstat)
161-
allow(Dir).to receive(:entries).with(subpath, encoding: Encoding::UTF_8).and_return(sub_names)
161+
allow(Dir).to receive(:entries).with(subpath, {encoding: Encoding::UTF_8}).and_return(sub_names)
162162
sub_names.each do |file|
163163
@files << File.join(subdir, file) # relative path
164164
subfile_path = File.join(subpath, file)
@@ -176,12 +176,12 @@ def mock_big_dir_structure(path, stat_method = :lstat)
176176
top_names = (1..10).map {|i| "dir_#{i}" }
177177
sub_names = (1..100).map {|i| "file__#{i}" }
178178

179-
allow(Dir).to receive(:entries).with(path, encoding: Encoding::UTF_8).and_return(top_names)
179+
allow(Dir).to receive(:entries).with(path, {encoding: Encoding::UTF_8}).and_return(top_names)
180180
top_names.each do |subdir|
181181
@files << subdir # relative path
182182
subpath = File.join(path, subdir)
183183
allow(Puppet::FileSystem).to receive(stat_method).with(subpath).and_return(@dirstat)
184-
allow(Dir).to receive(:entries).with(subpath, encoding: Encoding::UTF_8).and_return(sub_names)
184+
allow(Dir).to receive(:entries).with(subpath, {encoding: Encoding::UTF_8}).and_return(sub_names)
185185
sub_names.each do |file|
186186
@files << File.join(subdir, file) # relative path
187187
subfile_path = File.join(subpath, file)
@@ -193,7 +193,7 @@ def mock_big_dir_structure(path, stat_method = :lstat)
193193
def setup_mocks_for_dir(mock_dir, base_path)
194194
path = File.join(base_path, mock_dir.name)
195195
allow(Puppet::FileSystem).to receive(:lstat).with(path).and_return(MockStat.new(path, true))
196-
allow(Dir).to receive(:entries).with(path, encoding: Encoding::UTF_8).and_return(['.', '..'] + mock_dir.entries.map(&:name))
196+
allow(Dir).to receive(:entries).with(path, {encoding: Encoding::UTF_8}).and_return(['.', '..'] + mock_dir.entries.map(&:name))
197197
mock_dir.entries.each do |entry|
198198
setup_mocks_for_entry(entry, path)
199199
end
@@ -360,7 +360,7 @@ def directory?
360360
link_path = File.join(path, "mylink")
361361
expect(Puppet::FileSystem).to receive(:stat).with(link_path).and_raise(Errno::ENOENT)
362362

363-
allow(Dir).to receive(:entries).with(path, encoding: Encoding::UTF_8).and_return(["mylink"])
363+
allow(Dir).to receive(:entries).with(path, {encoding: Encoding::UTF_8}).and_return(["mylink"])
364364

365365
fileset = Puppet::FileServing::Fileset.new(path)
366366

@@ -377,16 +377,16 @@ def directory?
377377

378378
@filesets = @paths.collect do |path|
379379
allow(Puppet::FileSystem).to receive(:lstat).with(path).and_return(double('stat', :directory? => true))
380-
Puppet::FileServing::Fileset.new(path, :recurse => true)
380+
Puppet::FileServing::Fileset.new(path, {:recurse => true})
381381
end
382382

383383
allow(Dir).to receive(:entries).and_return([])
384384
end
385385

386386
it "returns a hash of all files in each fileset with the value being the base path" do
387-
expect(Dir).to receive(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).and_return(%w{one uno})
388-
expect(Dir).to receive(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).and_return(%w{two dos})
389-
expect(Dir).to receive(:entries).with(make_absolute("/third/path"), encoding: Encoding::UTF_8).and_return(%w{three tres})
387+
expect(Dir).to receive(:entries).with(make_absolute("/first/path"), {encoding: Encoding::UTF_8}).and_return(%w{one uno})
388+
expect(Dir).to receive(:entries).with(make_absolute("/second/path"), {encoding: Encoding::UTF_8}).and_return(%w{two dos})
389+
expect(Dir).to receive(:entries).with(make_absolute("/third/path"), {encoding: Encoding::UTF_8}).and_return(%w{three tres})
390390

391391
expect(Puppet::FileServing::Fileset.merge(*@filesets)).to eq({
392392
"." => make_absolute("/first/path"),
@@ -400,15 +400,15 @@ def directory?
400400
end
401401

402402
it "includes the base directory from the first fileset" do
403-
expect(Dir).to receive(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).and_return(%w{one})
404-
expect(Dir).to receive(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).and_return(%w{two})
403+
expect(Dir).to receive(:entries).with(make_absolute("/first/path"), {encoding: Encoding::UTF_8}).and_return(%w{one})
404+
expect(Dir).to receive(:entries).with(make_absolute("/second/path"), {encoding: Encoding::UTF_8}).and_return(%w{two})
405405

406406
expect(Puppet::FileServing::Fileset.merge(*@filesets)["."]).to eq(make_absolute("/first/path"))
407407
end
408408

409409
it "uses the base path of the first found file when relative file paths conflict" do
410-
expect(Dir).to receive(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).and_return(%w{one})
411-
expect(Dir).to receive(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).and_return(%w{one})
410+
expect(Dir).to receive(:entries).with(make_absolute("/first/path"), {encoding: Encoding::UTF_8}).and_return(%w{one})
411+
expect(Dir).to receive(:entries).with(make_absolute("/second/path"), {encoding: Encoding::UTF_8}).and_return(%w{one})
412412

413413
expect(Puppet::FileServing::Fileset.merge(*@filesets)["one"]).to eq(make_absolute("/first/path"))
414414
end

spec/unit/graph/simple_graph_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def expect_cycle_to_include(cycle, *resource_names)
475475

476476
it "should write a dot file based on the passed name" do
477477
expect(File).to receive(:open).with(@file, "w:UTF-8").and_yield(double("file", :puts => nil))
478-
expect(@graph).to receive(:to_dot).with("name" => @name.to_s.capitalize)
478+
expect(@graph).to receive(:to_dot).with({"name" => @name.to_s.capitalize})
479479
Puppet[:graph] = true
480480
@graph.write_graph(@name)
481481
end

spec/unit/indirector/file_server_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ class Puppet::FileTestModel::FileServer < Puppet::Indirector::FileServer
183183
expect(Puppet::FileServing::Fileset).to receive(:merge).and_return("one" => "/one", "two" => "/two")
184184

185185
one = double('one', :collect => nil)
186-
expect(model).to receive(:new).with("/one", :relative_path => "one").and_return(one)
186+
expect(model).to receive(:new).with("/one", {:relative_path => "one"}).and_return(one)
187187

188188
two = double('two', :collect => nil)
189-
expect(model).to receive(:new).with("/two", :relative_path => "two").and_return(two)
189+
expect(model).to receive(:new).with("/two", {:relative_path => "two"}).and_return(two)
190190

191191
# order can't be guaranteed
192192
result = indirection.search(uri)
@@ -205,7 +205,7 @@ class Puppet::FileTestModel::FileServer < Puppet::Indirector::FileServer
205205
expect(Puppet::FileServing::Fileset).to receive(:merge).and_return("one" => "/one")
206206

207207
one = double('one', :collect => nil)
208-
expect(model).to receive(:new).with("/one", :relative_path => "one").and_return(one)
208+
expect(model).to receive(:new).with("/one", {:relative_path => "one"}).and_return(one)
209209
expect(one).to receive(:links=).with(true)
210210

211211
indirection.search(uri, links: true)
@@ -221,7 +221,7 @@ class Puppet::FileTestModel::FileServer < Puppet::Indirector::FileServer
221221
expect(Puppet::FileServing::Fileset).to receive(:merge).and_return("one" => "/one")
222222

223223
one = double('one', :collect => nil)
224-
expect(model).to receive(:new).with("/one", :relative_path => "one").and_return(one)
224+
expect(model).to receive(:new).with("/one", {:relative_path => "one"}).and_return(one)
225225

226226
expect(one).to receive(:checksum_type=).with(:checksum)
227227

@@ -238,7 +238,7 @@ class Puppet::FileTestModel::FileServer < Puppet::Indirector::FileServer
238238
expect(Puppet::FileServing::Fileset).to receive(:merge).and_return("one" => "/one")
239239

240240
one = double('one')
241-
expect(model).to receive(:new).with("/one", :relative_path => "one").and_return(one)
241+
expect(model).to receive(:new).with("/one", {:relative_path => "one"}).and_return(one)
242242
expect(one).to receive(:collect)
243243

244244
indirection.search(uri)

spec/unit/indirector/node/plain_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
end
2222

2323
it "should find facts if none are supplied" do
24-
expect(Puppet::Node::Facts.indirection).to receive(:find).with(nodename, :environment => environment).and_return(indirection_facts)
24+
expect(Puppet::Node::Facts.indirection).to receive(:find).with(nodename, {:environment => environment}).and_return(indirection_facts)
2525
request.options.delete(:facts)
2626
node = node_indirection.find(request)
2727
expect(node.parameters).to include(indirection_fact_values)

spec/unit/provider/ldap_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
it "should create a provider with :ensure => :absent" do
7474
expect(@manager).to receive(:find).with("one").and_return(nil)
7575

76-
expect(@class).to receive(:new).with(:ensure => :absent).and_return("myprovider")
76+
expect(@class).to receive(:new).with({:ensure => :absent}).and_return("myprovider")
7777

7878
expect(@resource).to receive(:provider=).with("myprovider")
7979

spec/unit/provider/nameservice_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def modifycmd(param, value)
199199
it "should pass the Puppet::Etc :canonical_name Struct member to the constructor" do
200200
users = [ Struct::Passwd.new(invalid_utf_8_jose, invalid_utf_8_jose, 1002, 2000), nil ]
201201
allow(Etc).to receive(:getpwent).and_return(*users)
202-
expect(provider.class).to receive(:new).with(:name => escaped_utf_8_jose, :canonical_name => invalid_utf_8_jose, :ensure => :present)
202+
expect(provider.class).to receive(:new).with({:name => escaped_utf_8_jose, :canonical_name => invalid_utf_8_jose, :ensure => :present})
203203
provider.class.instances
204204
end
205205
end

spec/unit/provider/package/aix_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
it "should uninstall a package" do
1818
expect(@provider).to receive(:installp).with('-gu', 'mypackage')
19-
expect(@provider.class).to receive(:pkglist).with(:pkgname => 'mypackage').and_return(nil)
19+
expect(@provider.class).to receive(:pkglist).with({:pkgname => 'mypackage'}).and_return(nil)
2020
@provider.uninstall
2121
end
2222

spec/unit/provider/package/nim_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@
158158
it "should call installp to uninstall a bff package" do
159159
expect(@provider).to receive(:lslpp).with("-qLc", "mypackage.foo").and_return("#bos.atm:bos.atm.atmle:7.1.2.0: : :C: :ATM LAN Emulation Client Support : : : : : : :0:0:/:1241")
160160
expect(@provider).to receive(:installp).with("-gu", "mypackage.foo")
161-
expect(@provider.class).to receive(:pkglist).with(:pkgname => 'mypackage.foo').and_return(nil)
161+
expect(@provider.class).to receive(:pkglist).with({:pkgname => 'mypackage.foo'}).and_return(nil)
162162
@provider.uninstall
163163
end
164164

165165
it "should call rpm to uninstall an rpm package" do
166166
expect(@provider).to receive(:lslpp).with("-qLc", "mypackage.foo").and_return("cdrecord:cdrecord-1.9-6:1.9-6: : :C:R:A command line CD/DVD recording program.: :/bin/rpm -e cdrecord: : : : :0: :/opt/freeware:Wed Jun 29 09:41:32 PDT 2005")
167167
expect(@provider).to receive(:rpm).with("-e", "mypackage.foo")
168-
expect(@provider.class).to receive(:pkglist).with(:pkgname => 'mypackage.foo').and_return(nil)
168+
expect(@provider.class).to receive(:pkglist).with({:pkgname => 'mypackage.foo'}).and_return(nil)
169169
@provider.uninstall
170170
end
171171
end

spec/unit/provider/service/bsd_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@
9494

9595
it "should use the supplied start command if specified" do
9696
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :start => '/bin/foo'))
97-
expect(provider).to receive(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
97+
expect(provider).to receive(:execute).with(['/bin/foo'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
9898
provider.start
9999
end
100100

101101
it "should start the serviced directly otherwise" do
102102
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
103-
expect(provider).to receive(:execute).with(['/etc/rc.d/sshd', :onestart], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
103+
expect(provider).to receive(:execute).with(['/etc/rc.d/sshd', :onestart], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
104104
expect(provider).to receive(:search).with('sshd').and_return('/etc/rc.d/sshd')
105105
provider.start
106106
end
@@ -113,13 +113,13 @@
113113

114114
it "should use the supplied stop command if specified" do
115115
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :stop => '/bin/foo'))
116-
expect(provider).to receive(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
116+
expect(provider).to receive(:execute).with(['/bin/foo'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
117117
provider.stop
118118
end
119119

120120
it "should stop the serviced directly otherwise" do
121121
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
122-
expect(provider).to receive(:execute).with(['/etc/rc.d/sshd', :onestop], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
122+
expect(provider).to receive(:execute).with(['/etc/rc.d/sshd', :onestop], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
123123
expect(provider).to receive(:search).with('sshd').and_return('/etc/rc.d/sshd')
124124
provider.stop
125125
end

spec/unit/provider/service/debian_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
context "when checking whether it is enabled" do
8989
it "should execute the query command" do
90-
expect(@provider).to receive(:execute).with(["/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start"], :failonfail => false)
90+
expect(@provider).to receive(:execute).with(["/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start"], {:failonfail => false})
9191
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
9292
@provider.enabled?
9393
end
@@ -104,7 +104,7 @@
104104

105105
it "should consider nonexistent services to be disabled" do
106106
@provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'doesnotexist'))
107-
expect(@provider).to receive(:execute).with(["/usr/sbin/invoke-rc.d", "--quiet", "--query", "doesnotexist", "start"], :failonfail => false)
107+
expect(@provider).to receive(:execute).with(["/usr/sbin/invoke-rc.d", "--quiet", "--query", "doesnotexist", "start"], {:failonfail => false})
108108
.and_return(Puppet::Util::Execution::ProcessOutput.new("", 1))
109109
expect(@provider.enabled?).to be(:false)
110110
end

0 commit comments

Comments
 (0)