spec/ezmlm/list_spec.rb
changeset 6 66beb495a861
parent 5 804e1c2b9a40
child 12 3cc813140c80
equal deleted inserted replaced
5:804e1c2b9a40 6:66beb495a861
    26 
    26 
    27 describe Ezmlm::List do
    27 describe Ezmlm::List do
    28 	include Ezmlm::SpecHelpers
    28 	include Ezmlm::SpecHelpers
    29 
    29 
    30 
    30 
    31 	LISTDIR = Pathname.new( 'list' )
    31 	# Testing constants
       
    32 	TEST_LISTDIR               = Pathname.new( 'list' )
       
    33 	TEST_LIST_NAME             = 'waffle-lovers'
       
    34 	TEST_LIST_HOST             = 'lists.syrup.info'
       
    35 	TEST_OWNER                 = 'listowner@rumpus-the-whale.info'
       
    36 	TEST_CUSTOM_MODERATORS_DIR = '/foo/bar/clowns'
       
    37 	
    32 	TEST_SUBSCRIBERS = %w[
    38 	TEST_SUBSCRIBERS = %w[
    33 		pete.chaffee@toadsmackers.com
    39 		pete.chaffee@toadsmackers.com
    34 		dolphinzombie@alahalohamorra.com
    40 		dolphinzombie@alahalohamorra.com
    35 		piratebanker@yahoo.com
    41 		piratebanker@yahoo.com
    36 	  ]
    42 	  ]
       
    43 
    37 	TEST_MODERATORS = %w[
    44 	TEST_MODERATORS = %w[
    38 		dolphinzombie@alahalohamorra.com
    45 		dolphinzombie@alahalohamorra.com
    39 	  ]
    46 	  ]
    40 	TEST_LIST_NAME = 'waffle-lovers'
    47 	
    41 	TEST_LIST_HOST = 'lists.syrup.info'
       
    42 	TEST_OWNER = 'listowner@rumpus-the-whale.info'
       
    43 	TEST_CUSTOM_MODERATORS_DIR = '/foo/bar/clowns'
       
    44 	TEST_CONFIG = <<-"EOF".gsub( /^\t+/, '' )
    48 	TEST_CONFIG = <<-"EOF".gsub( /^\t+/, '' )
    45 		F:-aBCDeFGHijKlMnOpQrStUVWXYZ
    49 		F:-aBCDeFGHijKlMnOpQrStUVWXYZ
    46 		X:
    50 		X:
    47 		D:/var/qmail/alias/lists/waffle-lovers/
    51 		D:/var/qmail/alias/lists/waffle-lovers/
    48 		T:/var/qmail/alias/.qmail-waffle-lovers
    52 		T:/var/qmail/alias/.qmail-waffle-lovers
    58 		8:
    62 		8:
    59 		9:
    63 		9:
    60 	EOF
    64 	EOF
    61 	
    65 	
    62 
    66 
    63 	it "can create a new list"
    67 	it "can create a list"
    64 	it "can add a new subscriber"
    68 	it "can add a new subscriber"
    65 	it "can remove a current subscriber"
    69 	it "can remove a current subscriber"
    66 	it "can edit the list's text files"
    70 	it "can edit the list's text files"
    67 
    71 
    68 
    72 
    70 	### List manager functions
    74 	### List manager functions
    71 	### 
    75 	### 
    72 	describe "list manager functions" do
    76 	describe "list manager functions" do
    73 		
    77 		
    74 		before( :each ) do
    78 		before( :each ) do
    75 			@listpath = LISTDIR.dup
    79 			@listpath = TEST_LISTDIR.dup
    76 			@list = Ezmlm::List.new( @listpath )
    80 			@list = Ezmlm::List.new( @listpath )
    77 		end
    81 		end
    78 		
    82 		
    79 		
    83 		
    80 		it "can return the configured list name" do
    84 		it "can return the configured list name" do
   119 			}.should raise_error( RuntimeError, /does not exist/ )
   123 			}.should raise_error( RuntimeError, /does not exist/ )
   120 		end
   124 		end
   121 
   125 
   122 		
   126 		
   123 		it "can return a list of subscribers' email addresses" do
   127 		it "can return a list of subscribers' email addresses" do
   124 			subscribers_dir = LISTDIR + 'subscribers'
   128 			subscribers_dir = TEST_LISTDIR + 'subscribers'
   125 			
   129 			
   126 			expectation = Pathname.should_receive( :glob ).with( subscribers_dir + '*' )
   130 			expectation = Pathname.should_receive( :glob ).with( subscribers_dir + '*' )
   127 
   131 
   128 			TEST_SUBSCRIBERS.each do |email|
   132 			TEST_SUBSCRIBERS.each do |email|
   129 				mock_subfile = mock( "Mock subscribers file for '#{email}'" )
   133 				mock_subfile = mock( "Mock subscribers file for '#{email}'" )
   391 	### Archive functions
   395 	### Archive functions
   392 	### 
   396 	### 
   393 	describe "archive functions" do
   397 	describe "archive functions" do
   394 	
   398 	
   395 		before( :each ) do
   399 		before( :each ) do
   396 			@listpath = LISTDIR.dup
   400 			@listpath = TEST_LISTDIR.dup
   397 			@list = Ezmlm::List.new( @listpath )
   401 			@list = Ezmlm::List.new( @listpath )
   398 		end
   402 		end
   399 		
   403 		
   400 		
   404 		
   401 		it "can return the count of archived posts" do
   405 		it "can return the count of archived posts" do
   417 			@list.message_count.should == 0
   421 			@list.message_count.should == 0
   418 		end
   422 		end
   419 		
   423 		
   420 
   424 
   421 		
   425 		
   422 		TEST_ARCHIVE_DIR = LISTDIR + 'archive'
   426 		TEST_ARCHIVE_DIR = TEST_LISTDIR + 'archive'
   423 		TEST_ARCHIVE_SUBDIRS = %w[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 ]
   427 		TEST_ARCHIVE_SUBDIRS = %w[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 ]
   424 		TEST_POST_FILES = %w[ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 ]
   428 		TEST_POST_FILES = %w[ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 ]
   425 
   429 
   426 		before( :each ) do
   430 		before( :each ) do
   427 			@archive_dir = TEST_ARCHIVE_DIR.dup
   431 			@archive_dir = TEST_ARCHIVE_DIR.dup