File: test_testing.rb

package info (click to toggle)
ruby-sidekiq 3.2.6~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,128 kB
  • ctags: 1,222
  • sloc: ruby: 5,848; makefile: 37; sh: 4
file content (82 lines) | stat: -rw-r--r-- 2,121 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require '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?
      end
    end

    describe 'require/load sidekiq/testing/inline.rb' do
      before do
        require 'sidekiq/testing/inline.rb'
      end

      after do
        Sidekiq::Testing.disable!
      end

      it 'enables inline testing' do
        Sidekiq::Testing.inline!
        assert_equal true, Sidekiq::Testing.enabled?
        assert_equal true, Sidekiq::Testing.inline?
      end

      it 'enables inline testing in a block' do
        Sidekiq::Testing.disable!
        assert_equal true, Sidekiq::Testing.disabled?

        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