1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/test/test_testing.rb

83 lines
2.1 KiB
Ruby
Raw Normal View History

require_relative 'helper'
require 'sidekiq'
require 'sidekiq/worker'
require 'active_record'
require 'action_mailer'
require 'sidekiq/rails'
require 'sidekiq/extensions/action_mailer'
require 'sidekiq/extensions/active_record'
Sidekiq.hook_rails!
class TestTesting < Sidekiq::Test
describe 'sidekiq testing' do
describe 'require/load sidekiq/testing.rb' do
before do
require 'sidekiq/testing.rb'
end
after do
Sidekiq::Testing.disable!
end
it 'enables fake testing' do
Sidekiq::Testing.fake!
assert_equal true, Sidekiq::Testing.enabled?
assert_equal true, Sidekiq::Testing.fake?
end
it 'enables fake testing in a block' do
Sidekiq::Testing.disable!
assert_equal true, Sidekiq::Testing.disabled?
Sidekiq::Testing.fake! do
assert_equal true, Sidekiq::Testing.enabled?
assert_equal true, Sidekiq::Testing.fake?
end
assert_equal false, Sidekiq::Testing.enabled?
assert_equal false, Sidekiq::Testing.fake?
end
it 'disables testing in a block' do
Sidekiq::Testing.fake!
Sidekiq::Testing.disable! do
assert_equal true, Sidekiq::Testing.disabled?
end
assert_equal true, Sidekiq::Testing.enabled?
2013-05-30 14:39:01 -04:00
end
end
describe 'require/load sidekiq/testing/inline.rb' do
before do
require 'sidekiq/testing/inline.rb'
2012-10-19 00:16:28 -04:00
end
after do
Sidekiq::Testing.disable!
2012-10-19 00:16:28 -04:00
end
it 'enables inline testing' do
Sidekiq::Testing.inline!
assert_equal true, Sidekiq::Testing.enabled?
assert_equal true, Sidekiq::Testing.inline?
end
2012-10-19 00:16:28 -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
Sidekiq::Testing.inline! do
assert_equal true, Sidekiq::Testing.enabled?
assert_equal true, Sidekiq::Testing.inline?
end
assert_equal false, Sidekiq::Testing.enabled?
assert_equal false, Sidekiq::Testing.inline?
end
end
end
end