rspec-sidekiq 1.1.0 → 2.0.0.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +1 -1
  3. data/.rspec +1 -1
  4. data/.simplecov +1 -1
  5. data/CHANGES.md +5 -0
  6. data/Gemfile +5 -5
  7. data/LICENSE +2 -2
  8. data/README.md +0 -4
  9. data/lib/rspec-sidekiq.rb +8 -7
  10. data/lib/rspec/sidekiq/batch.rb +4 -2
  11. data/lib/rspec/sidekiq/configuration.rb +2 -1
  12. data/lib/rspec/sidekiq/helpers.rb +3 -2
  13. data/lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb +5 -4
  14. data/lib/rspec/sidekiq/matchers.rb +8 -8
  15. data/lib/rspec/sidekiq/matchers/be_delayed.rb +1 -2
  16. data/lib/rspec/sidekiq/matchers/be_processed_in.rb +1 -2
  17. data/lib/rspec/sidekiq/matchers/be_retryable.rb +1 -2
  18. data/lib/rspec/sidekiq/matchers/be_unique.rb +1 -2
  19. data/lib/rspec/sidekiq/matchers/have_enqueued_job.rb +19 -9
  20. data/lib/rspec/sidekiq/sidekiq.rb +4 -3
  21. data/lib/rspec/sidekiq/version.rb +2 -1
  22. data/rspec-sidekiq.gemspec +25 -25
  23. data/spec/rspec/sidekiq/batch_spec.rb +10 -9
  24. data/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb +2 -2
  25. data/spec/rspec/sidekiq/matchers/be_delayed_spec.rb +87 -86
  26. data/spec/rspec/sidekiq/matchers/be_processed_in_spec.rb +42 -41
  27. data/spec/rspec/sidekiq/matchers/be_retryable_spec.rb +49 -48
  28. data/spec/rspec/sidekiq/matchers/be_unique_spec.rb +24 -23
  29. data/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +29 -28
  30. data/spec/rspec/sidekiq/sidekiq_spec.rb +8 -7
  31. data/spec/rspec/sidekiq/version_spec.rb +3 -2
  32. data/spec/spec_helper.rb +7 -6
  33. data/spec/support/factories.rb +4 -3
  34. data/spec/support/init.rb +4 -3
  35. data/spec/support/test_worker.rb +2 -1
  36. data/spec/support/test_worker_alternative.rb +3 -2
  37. metadata +23 -25
  38. data/lib/rspec/sidekiq/matchers/have_enqueued_jobs.rb +0 -12
  39. data/spec/rspec/sidekiq/matchers/have_enqueued_jobs_spec.rb +0 -9
@@ -1,4 +1,5 @@
1
- require "spec_helper"
1
+ # encoding: utf-8
2
+ require 'spec_helper'
2
3
 
3
4
  describe RSpec::Sidekiq::Matchers::BeRetryable do
4
5
  let(:specific_subject) { RSpec::Sidekiq::Matchers::BeRetryable.new 2 }
@@ -13,117 +14,117 @@ describe RSpec::Sidekiq::Matchers::BeRetryable do
13
14
  negative_subject.matches? negative_worker
14
15
  end
15
16
 
16
- describe "expected usage" do
17
- it "matches" do
17
+ describe 'expected usage' do
18
+ it 'matches' do
18
19
  expect(default_worker).to be_retryable true
19
20
  end
20
21
  end
21
22
 
22
- describe "#be_retryable" do
23
- it "returns instance" do
23
+ describe '#be_retryable' do
24
+ it 'returns instance' do
24
25
  expect(be_retryable true).to be_a RSpec::Sidekiq::Matchers::BeRetryable
25
26
  end
26
27
  end
27
28
 
28
- describe "#description" do
29
- context "when expected is a number" do
30
- it "returns description" do
31
- expect(specific_subject.description).to eq "retry 2 times"
29
+ describe '#description' do
30
+ context 'when expected is a number' do
31
+ it 'returns description' do
32
+ expect(specific_subject.description).to eq 'retry 2 times'
32
33
  end
33
34
  end
34
35
 
35
- context "when expected is true" do
36
- it "returns description" do
37
- expect(default_subject.description).to eq "retry the default number of times"
36
+ context 'when expected is true' do
37
+ it 'returns description' do
38
+ expect(default_subject.description).to eq 'retry the default number of times'
38
39
  end
39
40
  end
40
41
 
41
- context "when expected is false" do
42
- it "returns description" do
43
- expect(negative_subject.description).to eq "not retry"
42
+ context 'when expected is false' do
43
+ it 'returns description' do
44
+ expect(negative_subject.description).to eq 'not retry'
44
45
  end
45
46
  end
46
47
  end
47
48
 
48
- describe "#failure_message" do
49
- context "when expected is a number" do
50
- it "returns message" do
49
+ describe '#failure_message' do
50
+ context 'when expected is a number' do
51
+ it 'returns message' do
51
52
  expect(specific_subject.failure_message).to eq "expected #{specific_worker} to retry 2 times but got 2"
52
53
  end
53
54
  end
54
55
 
55
- context "when expected is true" do
56
- it "returns message" do
56
+ context 'when expected is true' do
57
+ it 'returns message' do
57
58
  expect(default_subject.failure_message).to eq "expected #{default_worker} to retry the default number of times but got true"
58
59
  end
59
60
  end
60
61
 
61
- context "when expected is false" do
62
- it "returns message" do
62
+ context 'when expected is false' do
63
+ it 'returns message' do
63
64
  expect(negative_subject.failure_message).to eq "expected #{negative_worker} to not retry but got false"
64
65
  end
65
66
  end
66
67
  end
67
68
 
68
- describe "#matches?" do
69
- context "when condition matches" do
70
- context "when expected is a number" do
71
- it "returns true" do
69
+ describe '#matches?' do
70
+ context 'when condition matches' do
71
+ context 'when expected is a number' do
72
+ it 'returns true' do
72
73
  expect(specific_subject.matches? specific_worker).to be true
73
74
  end
74
75
  end
75
76
 
76
- context "when expected is true" do
77
- it "returns true" do
77
+ context 'when expected is true' do
78
+ it 'returns true' do
78
79
  expect(default_subject.matches? default_worker).to be true
79
80
  end
80
81
  end
81
82
 
82
- context "when expected is false" do
83
- it "returns true" do
83
+ context 'when expected is false' do
84
+ it 'returns true' do
84
85
  expect(negative_subject.matches? negative_worker).to be true
85
86
  end
86
87
  end
87
88
  end
88
89
 
89
- context "when condition does not match" do
90
- context "when expected is a number" do
91
- it "returns false" do
90
+ context 'when condition does not match' do
91
+ context 'when expected is a number' do
92
+ it 'returns false' do
92
93
  expect(specific_subject.matches? default_worker).to be false
93
94
  end
94
95
  end
95
96
 
96
- context "when expected is true" do
97
- it "returns false" do
97
+ context 'when expected is true' do
98
+ it 'returns false' do
98
99
  expect(default_subject.matches? negative_worker).to be false
99
100
  end
100
101
  end
101
102
 
102
- context "when expected is false" do
103
- it "returns false" do
103
+ context 'when expected is false' do
104
+ it 'returns false' do
104
105
  expect(negative_subject.matches? specific_worker).to be false
105
106
  end
106
107
  end
107
108
  end
108
109
  end
109
110
 
110
- describe "#negative_failure_message" do
111
- context "when expected is a number" do
112
- it "returns message" do
113
- expect(specific_subject.negative_failure_message).to eq "expected #{specific_worker} to not retry 2 times"
111
+ describe '#failure_message_when_negated' do
112
+ context 'when expected is a number' do
113
+ it 'returns message' do
114
+ expect(specific_subject.failure_message_when_negated).to eq "expected #{specific_worker} to not retry 2 times"
114
115
  end
115
116
  end
116
117
 
117
- context "when expected is true" do
118
- it "returns message" do
119
- expect(default_subject.negative_failure_message).to eq "expected #{default_worker} to not retry the default number of times"
118
+ context 'when expected is true' do
119
+ it 'returns message' do
120
+ expect(default_subject.failure_message_when_negated).to eq "expected #{default_worker} to not retry the default number of times"
120
121
  end
121
122
  end
122
123
 
123
- context "when expected is false" do
124
- it "returns message" do
125
- expect(negative_subject.negative_failure_message).to eq "expected #{negative_worker} to retry"
124
+ context 'when expected is false' do
125
+ it 'returns message' do
126
+ expect(negative_subject.failure_message_when_negated).to eq "expected #{negative_worker} to retry"
126
127
  end
127
128
  end
128
129
  end
129
- end
130
+ end
@@ -1,62 +1,63 @@
1
- require "spec_helper"
1
+ # encoding: utf-8
2
+ require 'spec_helper'
2
3
 
3
4
  describe RSpec::Sidekiq::Matchers::BeUnique do
4
- shared_context "a unique worker" do
5
+ shared_context 'a unique worker' do
5
6
  before(:each) { subject.matches? @worker }
6
7
 
7
- describe "expected usage" do
8
- it "matches" do
8
+ describe 'expected usage' do
9
+ it 'matches' do
9
10
  expect(@worker).to be_unique
10
11
  end
11
12
 
12
- describe "#failure_message" do
13
- it "returns message" do
13
+ describe '#failure_message' do
14
+ it 'returns message' do
14
15
  expect(subject.failure_message).to eq "expected #{@worker} to be unique in the queue"
15
16
  end
16
17
  end
17
18
 
18
19
  end
19
20
 
20
- describe "#matches?" do
21
- context "when condition matches" do
22
- it "returns true" do
21
+ describe '#matches?' do
22
+ context 'when condition matches' do
23
+ it 'returns true' do
23
24
  expect(subject.matches? @worker).to be true
24
25
  end
25
26
  end
26
27
 
27
- context "when condition does not match" do
28
- it "returns false" do
28
+ context 'when condition does not match' do
29
+ it 'returns false' do
29
30
  expect(subject.matches? create_worker unique: false).to be false
30
31
  end
31
32
  end
32
33
 
33
- describe "#negative_failure_message" do
34
- it "returns message" do
34
+ describe '#negative_failure_message' do
35
+ it 'returns message' do
35
36
  expect(subject.negative_failure_message).to eq "expected #{@worker} to not be unique in the queue"
36
37
  end
37
38
  end
38
39
  end
39
40
  end
40
41
 
41
- context "a scheduled worker" do
42
+ context 'a scheduled worker' do
42
43
  before { @worker = create_worker unique: :all }
43
- include_context "a unique worker"
44
+ include_context 'a unique worker'
44
45
  end
45
46
 
46
- context "a regular worker" do
47
- before { @worker = create_worker unique: true}
48
- include_context "a unique worker"
47
+ context 'a regular worker' do
48
+ before { @worker = create_worker unique: true }
49
+ include_context 'a unique worker'
49
50
  end
50
51
 
51
- describe "#be_unique" do
52
- it "returns instance" do
52
+ describe '#be_unique' do
53
+ it 'returns instance' do
53
54
  expect(be_unique).to be_a RSpec::Sidekiq::Matchers::BeUnique
54
55
  end
55
56
  end
56
57
 
57
- describe "#description" do
58
- it "returns description" do
59
- expect(subject.description).to eq "be unique in the queue"
58
+ describe '#failure_message_when_negated' do
59
+ it 'returns message' do
60
+ expect(subject.failure_message_when_negated).to eq "expected #{worker} to not be unique in the queue"
60
61
  end
61
62
  end
62
63
  end
@@ -1,73 +1,74 @@
1
- require "spec_helper"
1
+ # encoding: utf-8
2
+ require 'spec_helper'
2
3
 
3
4
  describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
4
- let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new ["string", 1, true] }
5
- let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [an_instance_of(String), an_instance_of(Fixnum), true] }
5
+ let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new ['string', 1, true] }
6
+ let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(Fixnum), true] }
6
7
  let(:worker) { create_worker }
7
8
  before(:each) do
8
- worker.perform_async "string", 1, true
9
+ worker.perform_async 'string', 1, true
9
10
  argument_subject.matches? worker
10
11
  end
11
12
 
12
- describe "expected usage" do
13
- it "matches" do
14
- expect(worker).to have_enqueued_job "string", 1, true
13
+ describe 'expected usage' do
14
+ it 'matches' do
15
+ expect(worker).to have_enqueued_job 'string', 1, true
15
16
  end
16
17
  end
17
18
 
18
- describe "#have_enqueued_job" do
19
- it "returns instance" do
19
+ describe '#have_enqueued_job' do
20
+ it 'returns instance' do
20
21
  expect(have_enqueued_job).to be_a RSpec::Sidekiq::Matchers::HaveEnqueuedJob
21
22
  end
22
23
  end
23
24
 
24
- describe "#description" do
25
- it "returns description" do
25
+ describe '#description' do
26
+ it 'returns description' do
26
27
  expect(argument_subject.description).to eq "have an enqueued #{worker} job with arguments [\"string\", 1, true]"
27
28
  end
28
29
  end
29
30
 
30
- describe "#failure_message" do
31
- it "returns message" do
31
+ describe '#failure_message' do
32
+ it 'returns message' do
32
33
  expect(argument_subject.failure_message).to eq "expected to have an enqueued #{worker} job with arguments [\"string\", 1, true]\n\nfound: [[\"string\", 1, true]]"
33
34
  end
34
35
  end
35
36
 
36
- describe "#matches?" do
37
- context "when condition matches" do
38
- context "when expected are arguments" do
39
- it "returns true" do
37
+ describe '#matches?' do
38
+ context 'when condition matches' do
39
+ context 'when expected are arguments' do
40
+ it 'returns true' do
40
41
  expect(argument_subject.matches? worker).to be true
41
42
  end
42
43
  end
43
44
 
44
- context "when expected are matchers" do
45
- it "returns true" do
45
+ context 'when expected are matchers' do
46
+ it 'returns true' do
46
47
  expect(matcher_subject.matches? worker).to be true
47
48
  end
48
49
  end
49
50
  end
50
51
 
51
- context "when condition does not match" do
52
+ context 'when condition does not match' do
52
53
  before(:each) { Sidekiq::Worker.clear_all }
53
54
 
54
- context "when expected are arguments" do
55
- it "returns false" do
55
+ context 'when expected are arguments' do
56
+ it 'returns false' do
56
57
  expect(argument_subject.matches? worker).to be false
57
58
  end
58
59
  end
59
60
 
60
- context "when expected are matchers" do
61
- it "returns false" do
61
+ context 'when expected are matchers' do
62
+ it 'returns false' do
62
63
  expect(matcher_subject.matches? worker).to be false
63
64
  end
64
65
  end
65
66
  end
66
67
  end
67
68
 
68
- describe "#negative_failure_message" do
69
- it "returns message" do
70
- expect(argument_subject.negative_failure_message).to eq "expected to not have an enqueued #{worker} job with arguments [\"string\", 1, true]"
69
+ describe '#failure_message_when_negated' do
70
+ it 'returns message' do
71
+ expect(argument_subject.failure_message_when_negated).to eq "expected to not have an enqueued #{worker} job with arguments [\"string\", 1, true]"
71
72
  end
72
73
  end
73
- end
74
+ end
@@ -1,15 +1,16 @@
1
- require "spec_helper"
1
+ # encoding: utf-8
2
+ require 'spec_helper'
2
3
 
3
4
  describe RSpec::Sidekiq do
4
- describe "#configure" do
5
- it "yields with configuration" do
6
- expect{ |block| RSpec::Sidekiq.configure(&block) }.to yield_with_args RSpec::Sidekiq.configuration
5
+ describe '#configure' do
6
+ it 'yields with configuration' do
7
+ expect { |block| RSpec::Sidekiq.configure(&block) }.to yield_with_args RSpec::Sidekiq.configuration
7
8
  end
8
9
  end
9
10
 
10
- describe "#configuration" do
11
- it "returns instance" do
11
+ describe '#configuration' do
12
+ it 'returns instance' do
12
13
  expect(RSpec::Sidekiq.configuration).to be_a RSpec::Sidekiq::Configuration
13
14
  end
14
15
  end
15
- end
16
+ end
@@ -1,5 +1,6 @@
1
- require "spec_helper"
1
+ # encoding: utf-8
2
+ require 'spec_helper'
2
3
 
3
4
  describe RSpec::Sidekiq::VERSION do
4
- expect_it { to eq("1.1.0") }
5
+ expect_it { to eq('2.0.0.beta') }
5
6
  end
@@ -1,10 +1,11 @@
1
- require "simplecov"
2
- require "coveralls"
1
+ # encoding: utf-8
2
+ require 'simplecov'
3
+ require 'coveralls'
3
4
 
4
- require "sidekiq"
5
- require "rspec-sidekiq"
5
+ require 'sidekiq'
6
+ require 'rspec-sidekiq'
6
7
 
7
- require_relative "support/init"
8
+ require_relative 'support/init'
8
9
 
9
10
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
10
11
  Coveralls::SimpleCov::Formatter,
@@ -25,4 +26,4 @@ end
25
26
  RSpec::Core::MemoizedHelpers.module_eval do
26
27
  alias to should
27
28
  alias to_not should_not
28
- end
29
+ end
@@ -1,10 +1,11 @@
1
+ # encoding: utf-8
1
2
  module RSpec
2
3
  module Sidekiq
3
4
  module Spec
4
5
  module Support
5
6
  module Factories
6
- def create_worker options = {}
7
- clazz_name = "Worker#{ rand(36 ** 10).to_s 36 }"
7
+ def create_worker(options = {})
8
+ clazz_name = "Worker#{ rand(36**10).to_s 36 }"
8
9
  clazz = Class.new do
9
10
  include ::Sidekiq::Worker
10
11
 
@@ -19,4 +20,4 @@ module RSpec
19
20
  end
20
21
  end
21
22
  end
22
- end
23
+ end
@@ -1,3 +1,4 @@
1
- require_relative "factories"
2
- require_relative "test_worker"
3
- require_relative "test_worker_alternative"
1
+ # encoding: utf-8
2
+ require_relative 'factories'
3
+ require_relative 'test_worker'
4
+ require_relative 'test_worker_alternative'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class TestWorker
2
3
  include Sidekiq::Worker
3
4
 
@@ -5,4 +6,4 @@ class TestWorker
5
6
 
6
7
  def perform
7
8
  end
8
- end
9
+ end