rspec-sidekiq 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3bfc0f5fbded94f5135119b53c455ff09156e70
4
- data.tar.gz: 4401a55dbbfc4da0e0fd47a0b096fe91bf78cd92
3
+ metadata.gz: 4e76f040dc9a72982978b86c4085e90a4efeab6f
4
+ data.tar.gz: 4f3531dc67714ce9f1aae2858b2e12c4baf80f2e
5
5
  SHA512:
6
- metadata.gz: 226211091e343370183a1f9c4ee031431be35259315e455686bd27aa015f9e293677105a4636e48fd56c591b33d84ebb93b2bf30faa2f284651cb7455d128a90
7
- data.tar.gz: c0432c59598027cf1c2647c5a7ed4259ed090c109710bd7d1230fece72e92b9c5c05f362e59bcbe3df91a9a266f768ea3e11aba23857a3ac2dbcc7d361f6dcb5
6
+ metadata.gz: 02c75664a4f650debe93f2a6a61d51ce5c8341c16388824f500d0d5afe75b7ab044a6606a2c3fab25649ea424f9da683da05e8ab71dd69893f54a9dc7cea5345
7
+ data.tar.gz: 7528d4c9f3cda76979b3118dee4069fdb86792e566e91bfd475703d2f107e5555ed1a850a0ff0e4b79b874f37b74261f2250bc28e148324555d22b31bdf4dbfd
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ 2.2.0
2
+ ---
3
+ * Fix typo in README file [bradhaydon#87]
4
+ * Fix type in readme [graudeejs#80]
5
+ * Matchers::HaveEnqueuedJob breaks on jobs with Hash arguments [erikogan#77]
6
+ * have_enqueued_job fails if args includes a Hash bug [gPrado#74]
7
+
1
8
  2.1.0
2
9
  ---
3
10
  * ActiveJob support [tarzan#71]
data/README.md CHANGED
@@ -91,7 +91,7 @@ sidekiq_options retry: 5
91
91
  # test with...
92
92
  expect(AwesomeJob).to be_retryable true # or
93
93
  it { is_expected.to be_retryable true }
94
- # ...or alternatively specifiy the number of times it should be retried
94
+ # ...or alternatively specify the number of times it should be retried
95
95
  expect(AwesomeJob).to be_retryable 5 # or
96
96
  it { is_expected.to be_retryable 5 }
97
97
  # ...or when it should not retry
@@ -136,7 +136,7 @@ it { is_expected.to_not be_expired_in 2.hours }
136
136
  ### have_enqueued_job
137
137
  *Describes that there should be an enqueued job with the specified arguments*
138
138
  ```ruby
139
- Awesomejob.perform_async 'Awesome', true
139
+ AwesomeJob.perform_async 'Awesome', true
140
140
  # test with...
141
141
  expect(AwesomeJob).to have_enqueued_job('Awesome', true)
142
142
  ```
@@ -9,7 +9,7 @@ module RSpec
9
9
  attr_reader :klass, :expected_arguments, :actual
10
10
 
11
11
  def initialize(expected_arguments)
12
- @expected_arguments = expected_arguments
12
+ @expected_arguments = normalize_arguments(expected_arguments)
13
13
  end
14
14
 
15
15
  def description
@@ -53,13 +53,25 @@ module RSpec
53
53
  end
54
54
 
55
55
  def job_arguments(hash)
56
- hash['arguments'] || hash['args'] unless hash.is_a? Array
56
+ hash['arguments'] || hash['args'] if hash.is_a? Hash
57
57
  end
58
58
 
59
59
  def contain_exactly?(arguments)
60
60
  exactly = RSpec::Matchers::BuiltIn::ContainExactly.new(expected_arguments)
61
61
  exactly.matches?(arguments)
62
62
  end
63
+
64
+ def normalize_arguments(args)
65
+ if args.is_a?(Array)
66
+ args.map{ |x| normalize_arguments(x) }
67
+ elsif args.is_a?(Hash)
68
+ args.each_with_object({}) do |(key, value), hash|
69
+ hash[key.to_s] = normalize_arguments(value)
70
+ end
71
+ else
72
+ args
73
+ end
74
+ end
63
75
  end
64
76
  end
65
77
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Sidekiq
3
- VERSION = '2.1.0'
3
+ VERSION = '2.2.0'
4
4
  end
5
5
  end
@@ -1,14 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.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 [be_a(String), be_a(Fixnum), true] }
4
+ let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new worker_args }
5
+ let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(Fixnum), true, be_a(Hash)] }
6
6
  let(:worker) { create_worker }
7
+ let(:worker_args) { ['string', 1, true, {key: 'value', nested: [{hash: true}]}] }
7
8
  let(:active_job) { create_active_job :mailers }
8
9
  let(:resource) { TestResource.new }
9
10
 
10
11
  before(:each) do
11
- worker.perform_async 'string', 1, true
12
+ worker.perform_async *worker_args
12
13
  active_job.perform_later 'someResource'
13
14
  active_job.perform_later(resource)
14
15
  TestActionMailer.testmail.deliver_later
@@ -18,11 +19,11 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
18
19
 
19
20
  describe 'expected usage' do
20
21
  it 'matches' do
21
- expect(worker).to have_enqueued_job 'string', 1, true
22
+ expect(worker).to have_enqueued_job *worker_args
22
23
  end
23
24
 
24
25
  it 'matches on the global Worker queue' do
25
- expect(Sidekiq::Worker).to have_enqueued_job 'string', 1, true
26
+ expect(Sidekiq::Worker).to have_enqueued_job *worker_args
26
27
  end
27
28
 
28
29
  it 'matches on an enqueued ActiveJob' do
@@ -59,13 +60,13 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
59
60
 
60
61
  describe '#description' do
61
62
  it 'returns description' do
62
- expect(argument_subject.description).to eq "have an enqueued #{worker} job with arguments [\"string\", 1, true]"
63
+ expect(argument_subject.description).to eq "have an enqueued #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"nested\"=>[{\"hash\"=>true}]}]"
63
64
  end
64
65
  end
65
66
 
66
67
  describe '#failure_message' do
67
68
  it 'returns message' do
68
- expect(argument_subject.failure_message).to eq "expected to have an enqueued #{worker} job with arguments [\"string\", 1, true]\n\nfound: [[\"string\", 1, true]]"
69
+ expect(argument_subject.failure_message).to eq "expected to have an enqueued #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"nested\"=>[{\"hash\"=>true}]}]\n\nfound: [[\"string\", 1, true, {\"key\"=>\"value\", \"nested\"=>[{\"hash\"=>true}]}]]"
69
70
  end
70
71
  end
71
72
 
@@ -103,7 +104,7 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
103
104
 
104
105
  describe '#failure_message_when_negated' do
105
106
  it 'returns message' do
106
- expect(argument_subject.failure_message_when_negated).to eq "expected to not have an enqueued #{worker} job with arguments [\"string\", 1, true]"
107
+ expect(argument_subject.failure_message_when_negated).to eq "expected to not have an enqueued #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"nested\"=>[{\"hash\"=>true}]}]"
107
108
  end
108
109
  end
109
110
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe RSpec::Sidekiq::VERSION do
4
- it { is_expected.to eq('2.1.0') }
4
+ it { is_expected.to eq('2.2.0') }
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Ostler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-05 00:00:00.000000000 Z
11
+ date: 2015-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.4.6
196
+ rubygems_version: 2.4.8
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: RSpec for Sidekiq