23 |
23 |
24 |
24 |
25 describe Ezmlm do |
25 describe Ezmlm do |
26 include Ezmlm::SpecHelpers |
26 include Ezmlm::SpecHelpers |
27 |
27 |
28 LISTSDIR = '/tmp/lists' |
28 TEST_LISTSDIR = '/tmp/lists' |
29 |
29 |
30 it "can iterate over all mailing lists in a specified directory" do |
30 it "can fetch a list of all mailing list subdirectories beneath a given directory" do |
31 file_entry = mock( "plain file" ) |
31 file_entry = mock( "plain file" ) |
32 file_entry.should_receive( :directory? ).and_return( false ) |
32 file_entry.should_receive( :directory? ).and_return( false ) |
33 |
33 |
34 nonexistant_mlentry = stub( "mailinglist path that doesn't exist", :exist? => false ) |
34 nonexistant_mlentry = stub( "mailinglist path that doesn't exist", :exist? => false ) |
35 nonml_dir_entry = stub( "directory with no mailinglist file", |
35 nonml_dir_entry = stub( "directory with no mailinglist file", |
37 |
37 |
38 existant_mlentry = stub( "mailinglist path that does exist", :exist? => true ) |
38 existant_mlentry = stub( "mailinglist path that does exist", :exist? => true ) |
39 ml_dir_entry = stub( "directory with a mailinglist file", :directory? => true, :+ => existant_mlentry ) |
39 ml_dir_entry = stub( "directory with a mailinglist file", :directory? => true, :+ => existant_mlentry ) |
40 |
40 |
41 Pathname.should_receive( :glob ).with( an_instance_of(Pathname) ). |
41 Pathname.should_receive( :glob ).with( an_instance_of(Pathname) ). |
42 and_yield( file_entry ). |
42 and_return([ file_entry, nonml_dir_entry, ml_dir_entry ]) |
43 and_yield( nonml_dir_entry ). |
|
44 and_yield( ml_dir_entry ) |
|
45 |
43 |
46 Ezmlm::List.should_receive( :new ).with( ml_dir_entry ).and_return( :listobject ) |
44 dirs = Ezmlm.find_directories( TEST_LISTSDIR ) |
|
45 |
|
46 dirs.should have(1).member |
|
47 dirs.should include( ml_dir_entry ) |
|
48 end |
|
49 |
|
50 |
|
51 it "can iterate over all mailing lists in a specified directory" do |
|
52 Ezmlm.should_receive( :find_directories ).with( TEST_LISTSDIR ).and_return([ :listdir1, :listdir2 ]) |
|
53 |
|
54 Ezmlm::List.should_receive( :new ).with( :listdir1 ).and_return( :listobject1 ) |
|
55 Ezmlm::List.should_receive( :new ).with( :listdir2 ).and_return( :listobject2 ) |
47 |
56 |
48 lists = [] |
57 lists = [] |
49 Ezmlm.each_list( LISTSDIR ) do |list| |
58 Ezmlm.each_list( TEST_LISTSDIR ) do |list| |
50 lists << list |
59 lists << list |
51 end |
60 end |
52 |
61 |
53 lists.should have(1).member |
62 lists.should have(2).members |
54 lists.should include( :listobject ) |
63 lists.should include( :listobject1, :listobject2 ) |
55 end |
64 end |
56 |
65 |
57 end |
66 end |
58 |
67 |
59 |
68 |