2014-12-30 15:54:58 -05:00
|
|
|
require_relative 'helper'
|
2012-03-10 16:07:19 -05:00
|
|
|
require 'sidekiq'
|
2012-02-10 00:46:44 -05:00
|
|
|
require 'sidekiq/worker'
|
2012-03-10 14:56:34 -05:00
|
|
|
require 'active_record'
|
|
|
|
require 'action_mailer'
|
2012-04-28 00:21:23 -04:00
|
|
|
require 'sidekiq/rails'
|
2012-03-10 14:56:34 -05:00
|
|
|
require 'sidekiq/extensions/action_mailer'
|
|
|
|
require 'sidekiq/extensions/active_record'
|
2012-02-10 00:46:44 -05:00
|
|
|
|
2012-03-10 16:07:19 -05:00
|
|
|
Sidekiq.hook_rails!
|
|
|
|
|
2013-09-22 17:38:33 -04:00
|
|
|
class TestTesting < Sidekiq::Test
|
2012-02-10 00:46:44 -05:00
|
|
|
describe 'sidekiq testing' do
|
2013-09-20 17:39:11 -04:00
|
|
|
describe 'require/load sidekiq/testing.rb' do
|
|
|
|
before do
|
|
|
|
require 'sidekiq/testing.rb'
|
2012-03-10 14:56:34 -05:00
|
|
|
end
|
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
after do
|
|
|
|
Sidekiq::Testing.disable!
|
2012-03-10 14:56:34 -05:00
|
|
|
end
|
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
it 'enables fake testing' do
|
|
|
|
Sidekiq::Testing.fake!
|
|
|
|
assert_equal true, Sidekiq::Testing.enabled?
|
|
|
|
assert_equal true, Sidekiq::Testing.fake?
|
2012-02-10 00:46:44 -05:00
|
|
|
end
|
2012-03-10 14:56:34 -05:00
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
it 'enables fake testing in a block' do
|
|
|
|
Sidekiq::Testing.disable!
|
|
|
|
assert_equal true, Sidekiq::Testing.disabled?
|
2012-03-10 14:56:34 -05:00
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
Sidekiq::Testing.fake! do
|
|
|
|
assert_equal true, Sidekiq::Testing.enabled?
|
|
|
|
assert_equal true, Sidekiq::Testing.fake?
|
|
|
|
end
|
2012-05-02 13:45:05 -04:00
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
assert_equal false, Sidekiq::Testing.enabled?
|
|
|
|
assert_equal false, Sidekiq::Testing.fake?
|
2012-05-02 13:45:05 -04:00
|
|
|
end
|
2013-03-28 00:24:47 -04:00
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
it 'disables testing in a block' do
|
|
|
|
Sidekiq::Testing.fake!
|
2013-07-01 17:31:20 -04:00
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
Sidekiq::Testing.disable! do
|
|
|
|
assert_equal true, Sidekiq::Testing.disabled?
|
2013-07-01 17:31:20 -04:00
|
|
|
end
|
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
assert_equal true, Sidekiq::Testing.enabled?
|
2013-05-30 14:39:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
describe 'require/load sidekiq/testing/inline.rb' do
|
|
|
|
before do
|
|
|
|
require 'sidekiq/testing/inline.rb'
|
2012-10-19 00:16:28 -04:00
|
|
|
end
|
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
after do
|
|
|
|
Sidekiq::Testing.disable!
|
2012-10-19 00:16:28 -04:00
|
|
|
end
|
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
it 'enables inline testing' do
|
|
|
|
Sidekiq::Testing.inline!
|
|
|
|
assert_equal true, Sidekiq::Testing.enabled?
|
|
|
|
assert_equal true, Sidekiq::Testing.inline?
|
2012-11-01 10:49:35 -04:00
|
|
|
end
|
2012-10-19 00:16:28 -04:00
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
it 'enables inline testing in a block' do
|
|
|
|
Sidekiq::Testing.disable!
|
|
|
|
assert_equal true, Sidekiq::Testing.disabled?
|
2012-10-19 00:16:28 -04:00
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
Sidekiq::Testing.inline! do
|
|
|
|
assert_equal true, Sidekiq::Testing.enabled?
|
|
|
|
assert_equal true, Sidekiq::Testing.inline?
|
|
|
|
end
|
2012-11-01 10:49:35 -04:00
|
|
|
|
2013-09-20 17:39:11 -04:00
|
|
|
assert_equal false, Sidekiq::Testing.enabled?
|
|
|
|
assert_equal false, Sidekiq::Testing.inline?
|
|
|
|
end
|
2012-11-01 10:49:35 -04:00
|
|
|
end
|
2012-02-10 00:46:44 -05:00
|
|
|
end
|
|
|
|
end
|