1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
ENV["TEST"] = 'true'
require 'rubygems'
require 'coveralls'
Coveralls.wear!
require 'minitest/autorun'
$:.unshift File.expand_path("../../lib")
require 'beaneater'
require 'timeout'
begin
require 'mocha/minitest'
rescue LoadError
require 'mocha'
end
require 'json'
class Minitest::Test
# Cleans up all jobs from specific tubes
#
# @example
# cleanup_tubes!(['foo'], @beanstalk)
#
def cleanup_tubes!(tubes, client=nil)
client ||= @beanstalk
tubes.each do |name|
client.tubes.find(name).clear
end
end
# Cleans up all jobs from all tubes known to the connection
def flush_all(client=nil)
client ||= @beanstalk
# Do not continue if it is a mock or the connection has been closed
return if !client.is_a?(Beaneater) || !client.connection.connection
client.tubes.all.each do |tube|
tube.clear
end
end
# Run clean up after each test to ensure clean state in all tests
def teardown
flush_all
end
end
|