Checkpoint commit.

This commit is contained in:
Michael Granger 2008-08-06 17:24:00 +00:00
parent cf10ef2d7b
commit 29d8053770
9 changed files with 1236 additions and 24 deletions

View file

@ -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 ]

View 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
#
#