spec/spec_helpers.rb
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--
Multiple changes. - Start converting from from the old 'config' file format where applicable. - Port the ezmlm address hashing algorithm for fast email lookups - Add subscription and unsubscription for primary and behavioral dirs - Add a safety check for writes to the list directory

#!/usr/bin/ruby

require 'simplecov' if ENV['COVERAGE']
require 'rspec'
require 'loggability/spechelpers'

module SpecHelpers

	TEST_LISTSDIR = ENV['TEST_LISTSDIR'] || '/tmp/lists'

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


RSpec.configure do |config|
	include SpecHelpers

	config.run_all_when_everything_filtered = true
	config.filter_run :focus
	config.order = 'random'
	config.mock_with( :rspec ) do |mock|
		mock.syntax = :expect
	end

	config.include( SpecHelpers )
end