spec/ezmlm_spec.rb
changeset 1 1d3cfd4837a8
child 6 66beb495a861
equal deleted inserted replaced
0:1b096869b568 1:1d3cfd4837a8
       
     1 #!/usr/bin/env ruby
       
     2 
       
     3 BEGIN {
       
     4 	require 'pathname'
       
     5 	basedir = Pathname.new( __FILE__ ).dirname.parent
       
     6 	
       
     7 	libdir = basedir + "lib"
       
     8 	
       
     9 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
       
    10 }
       
    11 
       
    12 begin
       
    13 	require 'spec/runner'
       
    14 	require 'spec/lib/helpers'
       
    15 	require 'ezmlm'
       
    16 rescue LoadError
       
    17 	unless Object.const_defined?( :Gem )
       
    18 		require 'rubygems'
       
    19 		retry
       
    20 	end
       
    21 	raise
       
    22 end
       
    23 
       
    24 
       
    25 describe Ezmlm do
       
    26 	include Ezmlm::SpecHelpers
       
    27 
       
    28 	LISTSDIR = '/tmp/lists'
       
    29 
       
    30 	it "can iterate over all mailing lists in a specified directory" do
       
    31 		file_entry = mock( "plain file" )
       
    32 		file_entry.should_receive( :directory? ).and_return( false )
       
    33 
       
    34 		nonexistant_mlentry = stub( "mailinglist path that doesn't exist", :exist? => false )
       
    35 		nonml_dir_entry = stub( "directory with no mailinglist file",
       
    36 		 	:directory? => true, :+ => nonexistant_mlentry )
       
    37 
       
    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 )
       
    40 		
       
    41 		Pathname.should_receive( :glob ).with( an_instance_of(Pathname) ).
       
    42 			and_yield( file_entry ).
       
    43 			and_yield( nonml_dir_entry ).
       
    44 			and_yield( ml_dir_entry )
       
    45 
       
    46 		Ezmlm::List.should_receive( :new ).with( ml_dir_entry ).and_return( :listobject )
       
    47 		
       
    48 		lists = []
       
    49 		Ezmlm.each_list( LISTSDIR ) do |list|
       
    50 			lists << list
       
    51 		end
       
    52 		
       
    53 		lists.should have(1).member
       
    54 		lists.should include( :listobject )
       
    55 	end
       
    56 	
       
    57 end
       
    58 
       
    59