spec/spec_helpers.rb
changeset 12 3cc813140c80
parent 1 1d3cfd4837a8
child 14 cba9fb39bcdb
equal deleted inserted replaced
11:7fc2d1713795 12:3cc813140c80
       
     1 #!/usr/bin/ruby
       
     2 
       
     3 require 'simplecov' if ENV['COVERAGE']
       
     4 require 'rspec'
       
     5 require 'loggability/spechelpers'
       
     6 
       
     7 module SpecHelpers
       
     8 
       
     9 	TEST_LISTSDIR = ENV['TEST_LISTSDIR'] || '/tmp/lists'
       
    10 
       
    11 	###############
       
    12 	module_function
       
    13 	###############
       
    14 
       
    15 	### Create a temporary working directory and return
       
    16 	### a Pathname object for it.
       
    17 	###
       
    18 	def make_tempdir
       
    19 		dirname = "%s.%d.%0.4f" % [
       
    20 			'ezmlm_spec',
       
    21 			Process.pid,
       
    22 			(Time.now.to_f % 3600),
       
    23 		  ]
       
    24 		tempdir = Pathname.new( Dir.tmpdir ) + dirname
       
    25 		tempdir.mkpath
       
    26 
       
    27 		return tempdir
       
    28 	end
       
    29 end
       
    30 
       
    31 
       
    32 RSpec.configure do |config|
       
    33 	include SpecHelpers
       
    34 
       
    35 	config.run_all_when_everything_filtered = true
       
    36 	config.filter_run :focus
       
    37 	config.order = 'random'
       
    38 	config.mock_with( :rspec ) do |mock|
       
    39 		mock.syntax = :expect
       
    40 	end
       
    41 
       
    42 	config.include( SpecHelpers )
       
    43 end
       
    44 
       
    45