@@ -153,12 +153,12 @@ def mock_dir_structure(path, stat_method = :lstat)
153
153
top_names = %w{ one two .svn CVS }
154
154
sub_names = %w{ file1 file2 .svn CVS 0 false }
155
155
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 )
157
157
top_names . each do |subdir |
158
158
@files << subdir # relative path
159
159
subpath = File . join ( path , subdir )
160
160
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 )
162
162
sub_names . each do |file |
163
163
@files << File . join ( subdir , file ) # relative path
164
164
subfile_path = File . join ( subpath , file )
@@ -176,12 +176,12 @@ def mock_big_dir_structure(path, stat_method = :lstat)
176
176
top_names = ( 1 ..10 ) . map { |i | "dir_#{ i } " }
177
177
sub_names = ( 1 ..100 ) . map { |i | "file__#{ i } " }
178
178
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 )
180
180
top_names . each do |subdir |
181
181
@files << subdir # relative path
182
182
subpath = File . join ( path , subdir )
183
183
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 )
185
185
sub_names . each do |file |
186
186
@files << File . join ( subdir , file ) # relative path
187
187
subfile_path = File . join ( subpath , file )
@@ -193,7 +193,7 @@ def mock_big_dir_structure(path, stat_method = :lstat)
193
193
def setup_mocks_for_dir ( mock_dir , base_path )
194
194
path = File . join ( base_path , mock_dir . name )
195
195
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 ) )
197
197
mock_dir . entries . each do |entry |
198
198
setup_mocks_for_entry ( entry , path )
199
199
end
@@ -360,7 +360,7 @@ def directory?
360
360
link_path = File . join ( path , "mylink" )
361
361
expect ( Puppet ::FileSystem ) . to receive ( :stat ) . with ( link_path ) . and_raise ( Errno ::ENOENT )
362
362
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" ] )
364
364
365
365
fileset = Puppet ::FileServing ::Fileset . new ( path )
366
366
@@ -377,16 +377,16 @@ def directory?
377
377
378
378
@filesets = @paths . collect do |path |
379
379
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 } )
381
381
end
382
382
383
383
allow ( Dir ) . to receive ( :entries ) . and_return ( [ ] )
384
384
end
385
385
386
386
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 } )
390
390
391
391
expect ( Puppet ::FileServing ::Fileset . merge ( *@filesets ) ) . to eq ( {
392
392
"." => make_absolute ( "/first/path" ) ,
@@ -400,15 +400,15 @@ def directory?
400
400
end
401
401
402
402
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 } )
405
405
406
406
expect ( Puppet ::FileServing ::Fileset . merge ( *@filesets ) [ "." ] ) . to eq ( make_absolute ( "/first/path" ) )
407
407
end
408
408
409
409
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 } )
412
412
413
413
expect ( Puppet ::FileServing ::Fileset . merge ( *@filesets ) [ "one" ] ) . to eq ( make_absolute ( "/first/path" ) )
414
414
end
0 commit comments