Filled out the project, added Ezmlm module + spec.
This commit is contained in:
parent
4b12c97f6b
commit
00d3974363
15 changed files with 1548 additions and 0 deletions
33
spec/ezmlm/list_spec.rb
Normal file
33
spec/ezmlm/list_spec.rb
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/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 'spec/runner'
|
||||
require 'spec/lib/helpers'
|
||||
require 'ezmlm/list'
|
||||
rescue LoadError
|
||||
unless Object.const_defined?( :Gem )
|
||||
require 'rubygems'
|
||||
retry
|
||||
end
|
||||
raise
|
||||
end
|
||||
|
||||
|
||||
describe Ezmlm::List do
|
||||
include Ezmlm::SpecHelpers
|
||||
|
||||
|
||||
it "is well-tested"
|
||||
|
||||
end
|
||||
|
||||
|
||||
59
spec/ezmlm_spec.rb
Normal file
59
spec/ezmlm_spec.rb
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
BEGIN {
|
||||
require 'pathname'
|
||||
basedir = Pathname.new( __FILE__ ).dirname.parent
|
||||
|
||||
libdir = basedir + "lib"
|
||||
|
||||
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
||||
}
|
||||
|
||||
begin
|
||||
require 'spec/runner'
|
||||
require 'spec/lib/helpers'
|
||||
require 'ezmlm'
|
||||
rescue LoadError
|
||||
unless Object.const_defined?( :Gem )
|
||||
require 'rubygems'
|
||||
retry
|
||||
end
|
||||
raise
|
||||
end
|
||||
|
||||
|
||||
describe Ezmlm do
|
||||
include Ezmlm::SpecHelpers
|
||||
|
||||
LISTSDIR = '/tmp/lists'
|
||||
|
||||
it "can iterate over all mailing lists in a specified directory" do
|
||||
file_entry = mock( "plain file" )
|
||||
file_entry.should_receive( :directory? ).and_return( false )
|
||||
|
||||
nonexistant_mlentry = stub( "mailinglist path that doesn't exist", :exist? => false )
|
||||
nonml_dir_entry = stub( "directory with no mailinglist file",
|
||||
:directory? => true, :+ => nonexistant_mlentry )
|
||||
|
||||
existant_mlentry = stub( "mailinglist path that does exist", :exist? => true )
|
||||
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 )
|
||||
|
||||
Ezmlm::List.should_receive( :new ).with( ml_dir_entry ).and_return( :listobject )
|
||||
|
||||
lists = []
|
||||
Ezmlm.each_list( LISTSDIR ) do |list|
|
||||
lists << list
|
||||
end
|
||||
|
||||
lists.should have(1).member
|
||||
lists.should include( :listobject )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
157
spec/lib/helpers.rb
Normal file
157
spec/lib/helpers.rb
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
begin
|
||||
require 'ezmlm'
|
||||
rescue LoadError
|
||||
unless Object.const_defined?( :Gem )
|
||||
require 'rubygems'
|
||||
retry
|
||||
end
|
||||
raise
|
||||
end
|
||||
|
||||
module Ezmlm::SpecHelpers
|
||||
|
||||
###############
|
||||
module_function
|
||||
###############
|
||||
|
||||
### Create a temporary working directory and return
|
||||
### a Pathname object for it.
|
||||
###
|
||||
def make_tempdir
|
||||
dirname = "%s.%d.%0.4f" % [
|
||||
'ezmlm_spec',
|
||||
Process.pid,
|
||||
(Time.now.to_f % 3600),
|
||||
]
|
||||
tempdir = Pathname.new( Dir.tmpdir ) + dirname
|
||||
tempdir.mkpath
|
||||
|
||||
return tempdir
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Override the badly-formatted output of the RSpec HTML formatter
|
||||
require 'spec/runner/formatter/html_formatter'
|
||||
|
||||
class Spec::Runner::Formatter::HtmlFormatter
|
||||
def example_failed( example, counter, failure )
|
||||
failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
|
||||
|
||||
unless @header_red
|
||||
@output.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>"
|
||||
@header_red = true
|
||||
end
|
||||
|
||||
unless @example_group_red
|
||||
css_class = 'example_group_%d' % [current_example_group_number]
|
||||
@output.puts " <script type=\"text/javascript\">makeRed('#{css_class}');</script>"
|
||||
@example_group_red = true
|
||||
end
|
||||
|
||||
move_progress()
|
||||
|
||||
@output.puts " <dd class=\"spec #{failure_style}\">",
|
||||
" <span class=\"failed_spec_name\">#{h(example.description)}</span>",
|
||||
" <div class=\"failure\" id=\"failure_#{counter}\">"
|
||||
if failure.exception
|
||||
backtrace = format_backtrace( failure.exception.backtrace )
|
||||
message = failure.exception.message
|
||||
|
||||
@output.puts " <div class=\"message\"><code>#{h message}</code></div>",
|
||||
" <div class=\"backtrace\"><pre>#{backtrace}</pre></div>"
|
||||
end
|
||||
|
||||
if extra = extra_failure_content( failure )
|
||||
@output.puts( extra )
|
||||
end
|
||||
|
||||
@output.puts " </div>",
|
||||
" </dd>"
|
||||
@output.flush
|
||||
end
|
||||
|
||||
|
||||
alias_method :default_global_styles, :global_styles
|
||||
|
||||
def global_styles
|
||||
css = default_global_styles()
|
||||
css << %Q{
|
||||
/* Stuff added by #{__FILE__} */
|
||||
|
||||
/* Overrides */
|
||||
#rspec-header {
|
||||
-webkit-box-shadow: #333 0 2px 5px;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.example_group dt {
|
||||
-webkit-box-shadow: #333 0 2px 3px;
|
||||
}
|
||||
|
||||
/* Style for log output */
|
||||
dd.log-message {
|
||||
background: #eee;
|
||||
padding: 0 2em;
|
||||
margin: 0.2em 1em;
|
||||
border-bottom: 1px dotted #999;
|
||||
border-top: 1px dotted #999;
|
||||
text-indent: -1em;
|
||||
}
|
||||
|
||||
/* Parts of the message */
|
||||
dd.log-message .log-time {
|
||||
font-weight: bold;
|
||||
}
|
||||
dd.log-message .log-time:after {
|
||||
content: ": ";
|
||||
}
|
||||
dd.log-message .log-level {
|
||||
font-variant: small-caps;
|
||||
border: 1px solid #ccc;
|
||||
padding: 1px 2px;
|
||||
}
|
||||
dd.log-message .log-name {
|
||||
font-size: 1.2em;
|
||||
color: #1e51b2;
|
||||
}
|
||||
dd.log-message .log-name:before { content: "«"; }
|
||||
dd.log-message .log-name:after { content: "»"; }
|
||||
|
||||
dd.log-message .log-message-text {
|
||||
padding-left: 4px;
|
||||
font-family: Monaco, "Andale Mono", "Vera Sans Mono", mono;
|
||||
}
|
||||
|
||||
|
||||
/* Distinguish levels */
|
||||
dd.log-message.debug { color: #666; }
|
||||
dd.log-message.info {}
|
||||
|
||||
dd.log-message.warn,
|
||||
dd.log-message.error {
|
||||
background: #ff9;
|
||||
}
|
||||
dd.log-message.error .log-level,
|
||||
dd.log-message.error .log-message-text {
|
||||
color: #900;
|
||||
}
|
||||
dd.log-message.fatal {
|
||||
background: #900;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
border: 0;
|
||||
}
|
||||
dd.log-message.fatal .log-name {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
return css
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue