Skip to content

Commit

Permalink
Merge 1583344 into 82634af
Browse files Browse the repository at this point in the history
  • Loading branch information
bk-one committed Sep 27, 2016
2 parents 82634af + 1583344 commit 3f8340b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -6,6 +6,8 @@ rvm:
- jruby
- rbx-2
script: "bundle exec rspec spec"
before_install:
- gem install bundler
matrix:
allow_failures:
- rvm: rbx-2
4 changes: 4 additions & 0 deletions CHANGES.md
@@ -1,3 +1,7 @@
2.2.1
---
* Backport Fix clash with rspec-rails

2.2.0
---
* Fix typo in README file [bradhaydon#87]
Expand Down
10 changes: 8 additions & 2 deletions lib/rspec/sidekiq/matchers/have_enqueued_job.rb
Expand Up @@ -4,6 +4,10 @@ module Matchers
def have_enqueued_job(*expected_arguments)
HaveEnqueuedJob.new expected_arguments
end
if Gem::Dependency.new('rspec-rails', '>= 3.4.0').matching_specs.max_by(&:version)
warn "[DEPRECATION] `have_enqueued_job` is deprecated. Please use `have_enqueued_sidekiq_job` instead."
alias have_enqueued_sidekiq_job have_enqueued_job
end

class HaveEnqueuedJob
attr_reader :klass, :expected_arguments, :actual
Expand Down Expand Up @@ -36,11 +40,11 @@ def failure_message_when_negated
def unwrapped_job_arguments(jobs)
if jobs.is_a? Hash
jobs.values.flatten.map do |job|
map_arguments(job).flatten
map_arguments(job)
end
else
map_arguments(jobs)
end
end.map { |job| job.flatten }
end

def map_arguments(job)
Expand Down Expand Up @@ -68,6 +72,8 @@ def normalize_arguments(args)
args.each_with_object({}) do |(key, value), hash|
hash[key.to_s] = normalize_arguments(value)
end
elsif args.is_a?(Symbol)
args.to_s
else
args
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/sidekiq/version.rb
@@ -1,5 +1,5 @@
module RSpec
module Sidekiq
VERSION = '2.2.0'
VERSION = '2.2.1'
end
end
1 change: 1 addition & 0 deletions rspec-sidekiq.gemspec
Expand Up @@ -13,6 +13,7 @@ Gem::Specification.new do |s|

s.add_dependency 'rspec', '~> 3.0', '>= 3.0.0'
s.add_dependency 'sidekiq', '>= 2.4.0'
s.add_dependency 'rspec-rails', '>= 3.4.0'

s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8.0'
s.add_development_dependency 'fuubar', '~> 2.0', '>= 2.0.0'
Expand Down
8 changes: 4 additions & 4 deletions spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb
Expand Up @@ -4,7 +4,7 @@
let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new worker_args }
let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(Fixnum), true, be_a(Hash)] }
let(:worker) { create_worker }
let(:worker_args) { ['string', 1, true, {key: 'value', nested: [{hash: true}]}] }
let(:worker_args) { ['string', 1, true, {key: 'value', bar: :foo, nested: [{hash: true}]}] }
let(:active_job) { create_active_job :mailers }
let(:resource) { TestResource.new }

Expand Down Expand Up @@ -60,13 +60,13 @@

describe '#description' do
it 'returns description' do
expect(argument_subject.description).to eq "have an enqueued #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"nested\"=>[{\"hash\"=>true}]}]"
expect(argument_subject.description).to eq "have an enqueued #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]"
end
end

describe '#failure_message' do
it 'returns message' do
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}]}]]"
expect(argument_subject.failure_message).to eq "expected to have an enqueued #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]\n\nfound: [[\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]]"
end
end

Expand Down Expand Up @@ -104,7 +104,7 @@

describe '#failure_message_when_negated' do
it 'returns message' do
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}]}]"
expect(argument_subject.failure_message_when_negated).to eq "expected to not have an enqueued #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]"
end
end
end
2 changes: 1 addition & 1 deletion spec/rspec/sidekiq/version_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'

RSpec.describe RSpec::Sidekiq::VERSION do
it { is_expected.to eq('2.2.0') }
it { is_expected.to eq('2.2.1') }
end

0 comments on commit 3f8340b

Please sign in to comment.