Sha256: 727ee0a487da282007339f70ea7feb4b4afc619a1c4878cd03773cf34dc70929

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

dir = File.dirname(File.expand_path(__FILE__))
$LOAD_PATH.unshift dir + '/../lib'

require 'rubygems'
require 'test/unit'
require 'related'
require 'redis/distributed'

#
# make sure we can run redis
#

if !system("which redis-server")
  puts '', "** can't find `redis-server` in your path"
  puts "** try running `sudo rake install`"
  abort ''
end


#
# start our own redis when the tests start,
# kill it when they end
#

at_exit do
  next if $!

  if defined?(MiniTest)
    exit_code = MiniTest::Unit.new.run(ARGV)
  else
    exit_code = Test::Unit::AutoRunner.run
  end

  puts "Killing test redis server..."
  loop do
    pid = `ps -A -o pid,command | grep [r]edis-test`.split(" ")[0]
    break if pid.nil?
    Process.kill("KILL", pid.to_i)
  end
  `rm -f #{dir}/*.rdb`
  exit exit_code
end

puts "Starting redis for testing..."

# `redis-server #{dir}/redis-test-1.conf`
# Related.redis = 'localhost:6379'

`redis-server #{dir}/redis-test-1.conf`
`redis-server #{dir}/redis-test-2.conf`
`redis-server #{dir}/redis-test-3.conf`
`redis-server #{dir}/redis-test-4.conf`

Related.redis = Redis::Distributed.new %w[
  redis://localhost:6379
  redis://localhost:6380
  redis://localhost:6381
  redis://localhost:6382],
  :tag => /^related:([^:]+)/

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
related-0.6.3 test/test_helper.rb
related-0.6.2 test/test_helper.rb
related-0.6.1 test/test_helper.rb
related-0.6.0 test/test_helper.rb