author | Mahlon E. Smith <mahlon@martini.nu> |
Fri, 03 Feb 2017 10:52:46 -0800 | |
changeset 13 | a03c08c289e9 |
parent 12 | 3cc813140c80 |
child 14 | cba9fb39bcdb |
permissions | -rw-r--r-- |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/env ruby |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
2 |
|
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
3 |
BEGIN { |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
4 |
require 'pathname' |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
5 |
basedir = Pathname.new( __FILE__ ).dirname.parent |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
6 |
libdir = basedir + "lib" |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
7 |
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir ) |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
8 |
} |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
9 |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
10 |
require_relative 'spec_helpers' |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
11 |
require 'ezmlm' |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
12 |
|
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
13 |
describe Ezmlm do |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
14 |
|
6 | 15 |
it "can fetch a list of all mailing list subdirectories beneath a given directory" do |
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
16 |
file_entry = double( "plain file" ) |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
17 |
expect( file_entry ).to receive( :directory? ).and_return( false ) |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
18 |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
19 |
nonexistant_mlentry = double( "mailinglist path that doesn't exist", :exist? => false ) |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
20 |
nonml_dir_entry = double( "directory with no mailinglist file", |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
21 |
:directory? => true, :+ => nonexistant_mlentry ) |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
22 |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
23 |
existant_mlentry = double( "mailinglist path that does exist", :exist? => true ) |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
24 |
ml_dir_entry = double( "directory with a mailinglist file", :directory? => true, :+ => existant_mlentry ) |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
25 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
26 |
expect( Pathname ).to receive( :glob ).with( an_instance_of(Pathname) ). |
6 | 27 |
and_return([ file_entry, nonml_dir_entry, ml_dir_entry ]) |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
28 |
|
6 | 29 |
dirs = Ezmlm.find_directories( TEST_LISTSDIR ) |
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
30 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
31 |
expect( dirs.size ).to eq( 1 ) |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
32 |
expect( dirs ).to include( ml_dir_entry ) |
6 | 33 |
end |
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
34 |
|
6 | 35 |
|
36 |
it "can iterate over all mailing lists in a specified directory" do |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
37 |
expect( Ezmlm ).to receive( :find_directories ).with( TEST_LISTSDIR ).and_return([ :listdir1, :listdir2 ]) |
6 | 38 |
|
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
39 |
expect( Ezmlm::List ).to receive( :new ).with( :listdir1 ).and_return( :listobject1 ) |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
40 |
expect( Ezmlm::List ).to receive( :new ).with( :listdir2 ).and_return( :listobject2 ) |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
41 |
|
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
42 |
lists = [] |
6 | 43 |
Ezmlm.each_list( TEST_LISTSDIR ) do |list| |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
44 |
lists << list |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
45 |
end |
12
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
46 |
|
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
47 |
expect( lists.size ).to eq(2) |
3cc813140c80
First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents:
6
diff
changeset
|
48 |
expect( lists ).to include( :listobject1, :listobject2 ) |
1
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
49 |
end |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
50 |
end |
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
51 |
|
1d3cfd4837a8
Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff
changeset
|
52 |