Checkpoint commit.
This commit is contained in:
parent
cf10ef2d7b
commit
29d8053770
9 changed files with 1236 additions and 24 deletions
|
|
@ -28,19 +28,23 @@ describe Ezmlm::List do
|
|||
include Ezmlm::SpecHelpers
|
||||
|
||||
|
||||
LISTDIR = Pathname.new( 'list' )
|
||||
# Testing constants
|
||||
TEST_LISTDIR = Pathname.new( 'list' )
|
||||
TEST_LIST_NAME = 'waffle-lovers'
|
||||
TEST_LIST_HOST = 'lists.syrup.info'
|
||||
TEST_OWNER = 'listowner@rumpus-the-whale.info'
|
||||
TEST_CUSTOM_MODERATORS_DIR = '/foo/bar/clowns'
|
||||
|
||||
TEST_SUBSCRIBERS = %w[
|
||||
pete.chaffee@toadsmackers.com
|
||||
dolphinzombie@alahalohamorra.com
|
||||
piratebanker@yahoo.com
|
||||
]
|
||||
|
||||
TEST_MODERATORS = %w[
|
||||
dolphinzombie@alahalohamorra.com
|
||||
]
|
||||
TEST_LIST_NAME = 'waffle-lovers'
|
||||
TEST_LIST_HOST = 'lists.syrup.info'
|
||||
TEST_OWNER = 'listowner@rumpus-the-whale.info'
|
||||
TEST_CUSTOM_MODERATORS_DIR = '/foo/bar/clowns'
|
||||
|
||||
TEST_CONFIG = <<-"EOF".gsub( /^\t+/, '' )
|
||||
F:-aBCDeFGHijKlMnOpQrStUVWXYZ
|
||||
X:
|
||||
|
|
@ -60,7 +64,7 @@ describe Ezmlm::List do
|
|||
EOF
|
||||
|
||||
|
||||
it "can create a new list"
|
||||
it "can create a list"
|
||||
it "can add a new subscriber"
|
||||
it "can remove a current subscriber"
|
||||
it "can edit the list's text files"
|
||||
|
|
@ -72,7 +76,7 @@ describe Ezmlm::List do
|
|||
describe "list manager functions" do
|
||||
|
||||
before( :each ) do
|
||||
@listpath = LISTDIR.dup
|
||||
@listpath = TEST_LISTDIR.dup
|
||||
@list = Ezmlm::List.new( @listpath )
|
||||
end
|
||||
|
||||
|
|
@ -121,7 +125,7 @@ describe Ezmlm::List do
|
|||
|
||||
|
||||
it "can return a list of subscribers' email addresses" do
|
||||
subscribers_dir = LISTDIR + 'subscribers'
|
||||
subscribers_dir = TEST_LISTDIR + 'subscribers'
|
||||
|
||||
expectation = Pathname.should_receive( :glob ).with( subscribers_dir + '*' )
|
||||
|
||||
|
|
@ -393,7 +397,7 @@ describe Ezmlm::List do
|
|||
describe "archive functions" do
|
||||
|
||||
before( :each ) do
|
||||
@listpath = LISTDIR.dup
|
||||
@listpath = TEST_LISTDIR.dup
|
||||
@list = Ezmlm::List.new( @listpath )
|
||||
end
|
||||
|
||||
|
|
@ -419,7 +423,7 @@ describe Ezmlm::List do
|
|||
|
||||
|
||||
|
||||
TEST_ARCHIVE_DIR = LISTDIR + 'archive'
|
||||
TEST_ARCHIVE_DIR = TEST_LISTDIR + 'archive'
|
||||
TEST_ARCHIVE_SUBDIRS = %w[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 ]
|
||||
TEST_POST_FILES = %w[ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 ]
|
||||
|
||||
|
|
|
|||
129
spec/ezmlm/listdaemon_spec.rb
Normal file
129
spec/ezmlm/listdaemon_spec.rb
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
BEGIN {
|
||||
require 'pathname'
|
||||
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
||||
|
||||
libdir = basedir + "lib"
|
||||
|
||||
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
||||
}
|
||||
|
||||
|
||||
begin
|
||||
require 'ostruct'
|
||||
require 'spec/runner'
|
||||
require 'spec/lib/helpers'
|
||||
require 'ezmlm/listdaemon'
|
||||
rescue LoadError
|
||||
unless Object.const_defined?( :Gem )
|
||||
require 'rubygems'
|
||||
retry
|
||||
end
|
||||
raise
|
||||
end
|
||||
|
||||
|
||||
describe Ezmlm::ListDaemon do
|
||||
include Ezmlm::SpecHelpers
|
||||
|
||||
|
||||
DEFAULT_ADDRESS = Ezmlm::ListDaemon::DEFAULT_ADDRESS
|
||||
DEFAULT_PORT = Ezmlm::ListDaemon::DEFAULT_PORT
|
||||
|
||||
|
||||
it "can return a struct that contains its default options" do
|
||||
opts = Ezmlm::ListDaemon.default_options
|
||||
|
||||
opts.should be_an_instance_of( OpenStruct )
|
||||
opts.bind_addr.should == DEFAULT_ADDRESS
|
||||
opts.bind_port.should == DEFAULT_PORT
|
||||
opts.debugmode.should == false
|
||||
opts.helpmode.should == false
|
||||
end
|
||||
|
||||
describe "created with defaults" do
|
||||
|
||||
DEFAULT_URL = "druby://%s:%d" % [ DEFAULT_ADDRESS, DEFAULT_PORT ]
|
||||
|
||||
before( :each ) do
|
||||
@test_list_dir = Pathname.new( 'lists' )
|
||||
@daemon = Ezmlm::ListDaemon.new( @test_list_dir )
|
||||
end
|
||||
|
||||
|
||||
it "can be started and will return a thread" do
|
||||
mock_drb_thread = mock( "drb thread" )
|
||||
|
||||
DRb.should_receive( :start_service ).with( DEFAULT_URL, @daemon.service )
|
||||
DRb.should_receive( :thread ).and_return( mock_drb_thread )
|
||||
|
||||
@daemon.start.should == mock_drb_thread
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "created with an options struct" do
|
||||
|
||||
TEST_ADDRESS = '0.0.0.0'
|
||||
TEST_PORT = 17771
|
||||
TEST_URL = "druby://%s:%d" % [ TEST_ADDRESS, TEST_PORT ]
|
||||
|
||||
before( :each ) do
|
||||
@test_list_dir = Pathname.new( 'lists' )
|
||||
|
||||
@opts = Ezmlm::ListDaemon.default_options
|
||||
@opts.bind_addr = TEST_ADDRESS
|
||||
@opts.bind_port = TEST_PORT
|
||||
|
||||
@daemon = Ezmlm::ListDaemon.new( @test_list_dir, @opts )
|
||||
end
|
||||
|
||||
|
||||
it "can be started and will return a thread" do
|
||||
mock_drb_thread = mock( "drb thread" )
|
||||
|
||||
DRb.should_receive( :start_service ).with( TEST_URL, @daemon.service )
|
||||
DRb.should_receive( :thread ).and_return( mock_drb_thread )
|
||||
|
||||
@daemon.start.should == mock_drb_thread
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
describe Ezmlm::ListDaemon::Service do
|
||||
|
||||
before( :each ) do
|
||||
@dummydir = 'lists'
|
||||
@service = Ezmlm::ListDaemon::Service.new( @dummydir )
|
||||
end
|
||||
|
||||
|
||||
it "can return a list object by name if there is a corresponding listdir" do
|
||||
@service.get_list( 'announce' ).should be_an_instance_of( Ezmlm::List )
|
||||
end
|
||||
|
||||
it "raises an exception when asked for a list whose name contains invalid characters" do
|
||||
lambda {
|
||||
@service.get_list( 'glarg beegun' )
|
||||
}.should raise_error( ArgumentError )
|
||||
end
|
||||
|
||||
it "can iterate over listdirs, yielding each as a Ezmlm::List object" do
|
||||
Ezmlm.should_receive( :each_list ).with( Pathname.new(@dummydir) ).and_yield( :a_list )
|
||||
@service.each_list {|l| l.should == :a_list }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# listservice = DRbObject.new( nil, 'druby://lists.laika.com:23431' )
|
||||
# announce = listservice.each_list do |list|
|
||||
# last_posts << list.last_post
|
||||
# end
|
||||
# announce = listservice.get_list( 'announce' )
|
||||
#
|
||||
# announce.last_post
|
||||
#
|
||||
#
|
||||
|
|
@ -25,9 +25,9 @@ end
|
|||
describe Ezmlm do
|
||||
include Ezmlm::SpecHelpers
|
||||
|
||||
LISTSDIR = '/tmp/lists'
|
||||
TEST_LISTSDIR = '/tmp/lists'
|
||||
|
||||
it "can iterate over all mailing lists in a specified directory" do
|
||||
it "can fetch a list of all mailing list subdirectories beneath a given directory" do
|
||||
file_entry = mock( "plain file" )
|
||||
file_entry.should_receive( :directory? ).and_return( false )
|
||||
|
||||
|
|
@ -39,19 +39,28 @@ describe Ezmlm do
|
|||
ml_dir_entry = stub( "directory with a mailinglist file", :directory? => true, :+ => existant_mlentry )
|
||||
|
||||
Pathname.should_receive( :glob ).with( an_instance_of(Pathname) ).
|
||||
and_yield( file_entry ).
|
||||
and_yield( nonml_dir_entry ).
|
||||
and_yield( ml_dir_entry )
|
||||
and_return([ file_entry, nonml_dir_entry, ml_dir_entry ])
|
||||
|
||||
Ezmlm::List.should_receive( :new ).with( ml_dir_entry ).and_return( :listobject )
|
||||
dirs = Ezmlm.find_directories( TEST_LISTSDIR )
|
||||
|
||||
dirs.should have(1).member
|
||||
dirs.should include( ml_dir_entry )
|
||||
end
|
||||
|
||||
|
||||
it "can iterate over all mailing lists in a specified directory" do
|
||||
Ezmlm.should_receive( :find_directories ).with( TEST_LISTSDIR ).and_return([ :listdir1, :listdir2 ])
|
||||
|
||||
Ezmlm::List.should_receive( :new ).with( :listdir1 ).and_return( :listobject1 )
|
||||
Ezmlm::List.should_receive( :new ).with( :listdir2 ).and_return( :listobject2 )
|
||||
|
||||
lists = []
|
||||
Ezmlm.each_list( LISTSDIR ) do |list|
|
||||
Ezmlm.each_list( TEST_LISTSDIR ) do |list|
|
||||
lists << list
|
||||
end
|
||||
|
||||
lists.should have(1).member
|
||||
lists.should include( :listobject )
|
||||
lists.should have(2).members
|
||||
lists.should include( :listobject1, :listobject2 )
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue