Sha256: 4e2a38bd225a2e556de45707aaa4896e8117970bde44f502240a725d4e3af54b

Contents?: true

Size: 1.8 KB

Versions: 35

Compression:

Stored size: 1.8 KB

Contents

# Pretty much copied this file from the resque test_helper since we want
# to do all the same stuff

dir = File.dirname(File.expand_path(__FILE__))

require 'rubygems'
require 'test/unit'
require 'mocha'
require 'resque'
require File.join(dir, '../lib/resque_scheduler')
$LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__)) + '/../lib'


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

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

puts "Starting redis for testing at localhost:9736..."
`redis-server #{dir}/redis-test.conf`
Resque.redis = 'localhost:9736'

##
# test/spec/mini 3
# http://gist.github.com/25455
# chris@ozmm.org
#
def context(*args, &block)
  return super unless (name = args.first) && block
  require 'test/unit'
  klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
    def self.test(name, &block)
      define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
    end 
    def self.xtest(*args) end 
    def self.setup(&block) define_method(:setup, &block) end 
    def self.teardown(&block) define_method(:teardown, &block) end 
  end 
  (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
  klass.class_eval &block
end

class SomeJob
  def self.perform(repo_id, path)
  end
end

class SomeIvarJob < SomeJob
  @queue = :ivar
end

Version data entries

35 entries across 35 versions & 5 rubygems

Version Path
brianjlandau-resque-scheduler-1.10.5 test/test_helper.rb
brianjlandau-resque-scheduler-1.10.4 test/test_helper.rb
brianjlandau-resque-scheduler-1.10.3 test/test_helper.rb
brianjlandau-resque-scheduler-1.10.2 test/test_helper.rb
brianjlandau-resque-scheduler-1.10.1 test/test_helper.rb
brianjlandau-resque-scheduler-1.10.0 test/test_helper.rb
resque-scheduler-1.9.6 test/test_helper.rb
resque-scheduler-1.9.5 test/test_helper.rb
resque-scheduler-1.9.4 test/test_helper.rb
resque-scheduler-1.9.3 test/test_helper.rb
resque-scheduler-1.9.2 test/test_helper.rb
resque-scheduler-1.9.1 test/test_helper.rb
resque-scheduler-1.8.2 test/test_helper.rb
resque-scheduler-1.8.1 test/test_helper.rb
resque-scheduler-1.8.0 test/test_helper.rb