spec/ezmlm_spec.rb
changeset 14 cba9fb39bcdb
parent 12 3cc813140c80
equal deleted inserted replaced
13:a03c08c289e9 14:cba9fb39bcdb
    21 			:directory? => true, :+ => nonexistant_mlentry )
    21 			:directory? => true, :+ => nonexistant_mlentry )
    22 
    22 
    23 		existant_mlentry = double( "mailinglist path that does exist", :exist? => true )
    23 		existant_mlentry = double( "mailinglist path that does exist", :exist? => true )
    24 		ml_dir_entry = double( "directory with a mailinglist file", :directory? => true, :+ => existant_mlentry )
    24 		ml_dir_entry = double( "directory with a mailinglist file", :directory? => true, :+ => existant_mlentry )
    25 
    25 
       
    26 		sorted_dirs = double( "sorted dirs" )
    26 		expect( Pathname ).to receive( :glob ).with( an_instance_of(Pathname) ).
    27 		expect( Pathname ).to receive( :glob ).with( an_instance_of(Pathname) ).
       
    28 			and_return( sorted_dirs )
       
    29 		expect( sorted_dirs ).to receive( :sort ).
    27 			and_return([ file_entry, nonml_dir_entry, ml_dir_entry ])
    30 			and_return([ file_entry, nonml_dir_entry, ml_dir_entry ])
    28 
    31 
    29 		dirs = Ezmlm.find_directories( TEST_LISTSDIR )
    32 		dirs = Ezmlm.find_directories( '/tmp' )
    30 
    33 
    31 		expect( dirs.size ).to eq( 1 )
    34 		expect( dirs.size ).to eq( 1 )
    32 		expect( dirs ).to include( ml_dir_entry )
    35 		expect( dirs ).to include( ml_dir_entry )
    33 	end
    36 	end
    34 
    37 
    35 
    38 
    36 	it "can iterate over all mailing lists in a specified directory" do
    39 	it "can iterate over all mailing lists in a specified directory" do
    37 		expect( Ezmlm ).to receive( :find_directories ).with( TEST_LISTSDIR ).and_return([ :listdir1, :listdir2 ])
    40 		expect( Ezmlm ).to receive( :find_directories ).with( '/tmp' ).and_return([ :listdir1, :listdir2 ])
    38 
    41 
    39 		expect( Ezmlm::List ).to receive( :new ).with( :listdir1 ).and_return( :listobject1 )
    42 		expect( Ezmlm::List ).to receive( :new ).with( :listdir1 ).and_return( :listobject1 )
    40 		expect( Ezmlm::List ).to receive( :new ).with( :listdir2 ).and_return( :listobject2 )
    43 		expect( Ezmlm::List ).to receive( :new ).with( :listdir2 ).and_return( :listobject2 )
    41 
    44 
    42 		lists = []
    45 		lists = []
    43 		Ezmlm.each_list( TEST_LISTSDIR ) do |list|
    46 		Ezmlm.each_list( '/tmp' ) do |list|
    44 			lists << list
    47 			lists << list
    45 		end
    48 		end
    46 
    49 
    47 		expect( lists.size ).to eq(2)
    50 		expect( lists.size ).to eq(2)
    48 		expect( lists ).to include( :listobject1, :listobject2 )
    51 		expect( lists ).to include( :listobject1, :listobject2 )