spec/spec_helpers.rb
changeset 14 cba9fb39bcdb
parent 12 3cc813140c80
child 15 a38e6916504c
equal deleted inserted replaced
13:a03c08c289e9 14:cba9fb39bcdb
     1 #!/usr/bin/ruby
     1 #!/usr/bin/ruby
     2 
     2 
     3 require 'simplecov' if ENV['COVERAGE']
     3 require 'simplecov' if ENV['COVERAGE']
     4 require 'rspec'
     4 require 'rspec'
     5 require 'loggability/spechelpers'
     5 require 'loggability/spechelpers'
       
     6 require 'fileutils'
     6 
     7 
     7 module SpecHelpers
     8 module SpecHelpers
       
     9 	include FileUtils
     8 
    10 
     9 	TEST_LISTSDIR = ENV['TEST_LISTSDIR'] || '/tmp/lists'
    11 	TEST_LIST_NAME = 'waffle-lovers'
       
    12 	TEST_LIST_HOST = 'lists.syrup.info'
       
    13 	TEST_OWNER     = 'listowner@rumpus-the-whale.info'
       
    14 
       
    15 	TEST_SUBSCRIBERS = %w[
       
    16 		pete.chaffee@toadsmackers.com
       
    17 		dolphinzombie@alahalohamorra.com
       
    18 		piratebanker@yahoo.com
       
    19 	]
       
    20 
       
    21 	TEST_MODERATORS = %w[
       
    22 		dolphinzombie@alahalohamorra.com
       
    23 	]
    10 
    24 
    11 	###############
    25 	###############
    12 	module_function
    26 	module_function
    13 	###############
    27 	###############
    14 
    28 
    15 	### Create a temporary working directory and return
    29 	### Create a copy of a fresh listdir into /tmp.
    16 	### a Pathname object for it.
       
    17 	###
    30 	###
    18 	def make_tempdir
    31 	def make_listdir
    19 		dirname = "%s.%d.%0.4f" % [
    32 		dirname = "/tmp/%s.%d.%0.4f" % [
    20 			'ezmlm_spec',
    33 			'ezmlm_list',
    21 			Process.pid,
    34 			Process.pid,
    22 			(Time.now.to_f % 3600),
    35 			(Time.now.to_f % 3600),
    23 		  ]
    36 		  ]
    24 		tempdir = Pathname.new( Dir.tmpdir ) + dirname
    37 		list = Pathname.new( __FILE__ ).dirname + 'data' + 'testlist'
    25 		tempdir.mkpath
    38 		cp_r( list.to_s, dirname )
    26 
    39 
    27 		return tempdir
    40 		return dirname
    28 	end
    41 	end
    29 end
    42 end
    30 
    43 
    31 
    44 
    32 RSpec.configure do |config|
    45 RSpec.configure do |config|