require 'fileutils' # Pidgin2Adium.oops and Pidgin2Adium.warn both use warn() to output errors. # Setting $-w (the warning level) to nil suppresses them, which makes for # much prettier test output. $-w=nil # OMGHAX # Wrap it in a lambda so that we can pass it to Spork.prefork, if spork is installed. prefork_block = lambda do # Loading more in this block will cause your tests to run faster. However, # if you change any configuration or code from libraries loaded here, you'll # need to restart spork for it take effect. $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'ext', 'balance_tags_c')) require 'pidgin2adium' require 'faker' require 'time' # for Time.zone_offset rspec_configure_block = lambda do |config| config.before(:all) do @current_dir = File.dirname(__FILE__) @aliases = %w{gabebw gabeb-w gbw me}.join(',') # -7 => "-0700" @current_tz_offset = sprintf("%+03d00", Time.zone_offset(Time.new.zone) / 3600) @logfile_path = File.join(@current_dir, "logfiles/") @text_logfile_path = "#{@logfile_path}/2006-12-21.223606.txt" @htm_logfile_path = "#{@logfile_path}/2008-01-15.071445-0500PST.htm" @html_logfile_path = "#{@logfile_path}/2008-01-15.071445-0500PST.html" @nonexistent_output_dir = File.join(@current_dir, "nonexistent_output_dir/") @output_dir = File.join(@current_dir, "output-dir/") FileUtils.rm_r(@nonexistent_output_dir, :force => true) end config.after(:all) do # Clean up. FileUtils.rm_r(@nonexistent_output_dir, :force => true) FileUtils.rm_r(@output_dir, :force => true) end end begin # RSpec 2 gem 'rspec', '>= 2.0.0.beta.18' require 'rspec' RSpec.configure(&rspec_configure_block) rescue Gem::LoadError # RSpec 1 gem 'rspec', '~> 1.3' require 'spec' require 'spec/autorun' Spec::Runner.configure(&rspec_configure_block) end end begin require 'rubygems' require 'spork' Spork.prefork(&prefork_block) Spork.each_run do # This code will be run each time you run your specs. end rescue LoadError puts 'To make the tests run faster, run "sudo gem install spork" then run "spork"' puts 'from the base pidgin2adium directory.' # Spork isn't installed. prefork_block.call end