Clean adapter_test.rb and skip test for sidekiq in unsupported rubies

This commit is contained in:
Abdelkader Boudih 2014-08-13 12:57:23 +00:00
parent 67f8b6b2bc
commit 9b209603d0
3 changed files with 33 additions and 64 deletions

22
Gemfile
View File

@ -36,17 +36,17 @@ end
gem 'dalli', '>= 2.2.1'
# ActiveJob
gem 'resque'
gem 'resque-scheduler'
gem 'sidekiq'
gem 'sucker_punch'
gem 'delayed_job'
gem 'queue_classic'
gem 'sneakers', '0.1.1.pre'
gem 'que'
gem 'backburner'
gem 'qu-rails', github: "bkeepers/qu", branch: "master"
gem 'qu-redis'
gem 'resque', require: false
gem 'resque-scheduler', require: false
gem 'sidekiq', require: false
gem 'sucker_punch', require: false
gem 'delayed_job', require: false
gem 'queue_classic', require: false
gem 'sneakers', '0.1.1.pre', require: false
gem 'que', require: false
gem 'backburner', require: false
gem 'qu-rails', github: "bkeepers/qu", branch: "master", require: false
gem 'qu-redis', require: false
# Add your own local bundler stuff
local_gemfile = File.dirname(__FILE__) + "/.Gemfile"

View File

@ -1,56 +1,8 @@
require 'helper'
class AdapterTest < ActiveSupport::TestCase
setup { @old_adapter = ActiveJob::Base.queue_adapter }
teardown { ActiveJob::Base.queue_adapter = @old_adapter }
test 'should load inline adapter' do
ActiveJob::Base.queue_adapter = :inline
assert_equal ActiveJob::QueueAdapters::InlineAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Delayed Job adapter' do
ActiveJob::Base.queue_adapter = :delayed_job
assert_equal ActiveJob::QueueAdapters::DelayedJobAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Qu adapter' do
ActiveJob::Base.queue_adapter = :qu
assert_equal ActiveJob::QueueAdapters::QuAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Que adapter' do
ActiveJob::Base.queue_adapter = :que
assert_equal ActiveJob::QueueAdapters::QueAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Queue Classic adapter' do
ActiveJob::Base.queue_adapter = :queue_classic
assert_equal ActiveJob::QueueAdapters::QueueClassicAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Resque adapter' do
ActiveJob::Base.queue_adapter = :resque
assert_equal ActiveJob::QueueAdapters::ResqueAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Sidekiq adapter' do
ActiveJob::Base.queue_adapter = :sidekiq
assert_equal ActiveJob::QueueAdapters::SidekiqAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Sucker Punch adapter' do
ActiveJob::Base.queue_adapter = :sucker_punch
assert_equal ActiveJob::QueueAdapters::SuckerPunchAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Sneakers adapter' do
ActiveJob::Base.queue_adapter = :sneakers
assert_equal ActiveJob::QueueAdapters::SneakersAdapter, ActiveJob::Base.queue_adapter
end
test 'should load Backburner adapter' do
ActiveJob::Base.queue_adapter = :backburner
assert_equal ActiveJob::QueueAdapters::BackburnerAdapter, ActiveJob::Base.queue_adapter
test "should load #{ENV['AJADAPTER']} adapter" do
ActiveJob::Base.queue_adapter = ENV['AJADAPTER'].to_sym
assert_equal ActiveJob::Base.queue_adapter, "active_job/queue_adapters/#{ENV['AJADAPTER']}_adapter".classify.constantize
end
end

View File

@ -2,9 +2,26 @@ require File.expand_path('../../../load_paths', __FILE__)
require 'active_job'
adapter = ENV['AJADAPTER'] || 'inline'
@adapter = ENV['AJADAPTER'] || 'inline'
require "adapters/#{adapter}"
def sidekiq?
@adapter == 'sidekiq'
end
def rubinius?
RUBY_ENGINE == 'rbx'
end
def ruby_193?
RUBY_VERSION == '1.9.3' && RUBY_ENGINE != 'java'
end
#Sidekiq don't work with MRI 1.9.3
#Travis uses rbx 2.6 which don't support unicode characters in methods.
#Remove the check when Travis change to rbx 2.7+
exit if sidekiq? && (ruby_193? || rubinius?)
require "adapters/#{@adapter}"
require 'active_support/testing/autorun'