From 2c2e3c5b31e300ea2c524c55562ddbcf2fd32546 Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Fri, 19 Oct 2018 10:21:33 +0200 Subject: [PATCH 1/9] Add support for latest ruby and rails --- .travis.yml | 11 ++++++----- gemfiles/upgrade.gemfile | 10 ++++++++++ spec/rspec/sidekiq/matchers/be_unique_spec.rb | 2 +- spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb | 9 ++++++++- 4 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 gemfiles/upgrade.gemfile diff --git a/.travis.yml b/.travis.yml index 8b38cf4..bb7ffad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,15 @@ rvm: - 2.2 - 2.3 - 2.4.1 + - 2.5.1 - jruby - rbx-2 +gemfile: + - gemfiles/ruby20.gemfile + - gemfiles/sidekiq4.gemfile + - gemfiles/upgrade.gemfile + script: "bundle exec rspec spec" before_install: @@ -15,8 +21,3 @@ matrix: allow_failures: - rvm: jruby - rvm: rbx-2 - include: - - rvm: 2.0 - gemfile: gemfiles/ruby20.gemfile - - rvm: 2.4 - gemfile: gemfiles/sidekiq4.gemfile diff --git a/gemfiles/upgrade.gemfile b/gemfiles/upgrade.gemfile new file mode 100644 index 0000000..762a331 --- /dev/null +++ b/gemfiles/upgrade.gemfile @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +gem 'sidekiq', '~> 5.2.2' +gem 'nokogiri', '~> 1.8.5' +gem 'rspec-core', '~> 3.8' +gem 'activejob', '~> 5.2' +gem 'actionmailer', '~> 5.2' +gem 'activerecord', '~> 5.2' + +gemspec :path => '../' diff --git a/spec/rspec/sidekiq/matchers/be_unique_spec.rb b/spec/rspec/sidekiq/matchers/be_unique_spec.rb index b998d32..26baf5f 100644 --- a/spec/rspec/sidekiq/matchers/be_unique_spec.rb +++ b/spec/rspec/sidekiq/matchers/be_unique_spec.rb @@ -108,7 +108,7 @@ context "without a uniquing solution" do it "raises an exception" do - expect{subject.unique_key}.to raise_error + expect{subject.unique_key}.to raise_error RuntimeError, 'No support found for Sidekiq unique jobs' end end end diff --git a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb index 47b4f92..963032a 100644 --- a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +++ b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb @@ -4,7 +4,14 @@ let(:tomorrow) { DateTime.now + 1 } let(:interval) { 3.minutes } 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(:number_class) do + if Gem::Version.new(RUBY_VERSION) > ::Gem::Version.new('2.4.0') + ::Integer + else + ::Fixnum + end + end + let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(number_class), true, be_a(Hash)] } let(:worker) { create_worker } let(:worker_args) { ['string', 1, true, { key: 'value', bar: :foo, nested: [{hash: true}] }] } let(:active_job) { create_active_job :mailers } From 902f5cac58ba3c09aa7964c39964a936a2c71e33 Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Mon, 22 Oct 2018 08:41:15 +0200 Subject: [PATCH 2/9] Using Integer everywhere --- spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb index 963032a..efe8b68 100644 --- a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +++ b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb @@ -4,13 +4,7 @@ let(:tomorrow) { DateTime.now + 1 } let(:interval) { 3.minutes } let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new worker_args } - let(:number_class) do - if Gem::Version.new(RUBY_VERSION) > ::Gem::Version.new('2.4.0') - ::Integer - else - ::Fixnum - end - end + let(:number_class) { ::Integer } let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(number_class), true, be_a(Hash)] } let(:worker) { create_worker } let(:worker_args) { ['string', 1, true, { key: 'value', bar: :foo, nested: [{hash: true}] }] } From 84d46ccaf45731b12f1d5cf74540a35234ae573b Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Mon, 22 Oct 2018 08:42:10 +0200 Subject: [PATCH 3/9] Don't need the placeholder --- spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb index efe8b68..46e750b 100644 --- a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +++ b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb @@ -4,8 +4,7 @@ let(:tomorrow) { DateTime.now + 1 } let(:interval) { 3.minutes } let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new worker_args } - let(:number_class) { ::Integer } - let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(number_class), true, be_a(Hash)] } + let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(Integer), true, be_a(Hash)] } let(:worker) { create_worker } let(:worker_args) { ['string', 1, true, { key: 'value', bar: :foo, nested: [{hash: true}] }] } let(:active_job) { create_active_job :mailers } From eb3dfdc443bbfed22284919acb0182dbf5cc3345 Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Mon, 17 Feb 2020 09:14:34 +0100 Subject: [PATCH 4/9] Implement the changes recommended by Mathieu --- .travis.yml | 10 +++++----- gemfiles/ruby20.gemfile | 6 ------ gemfiles/sidekiq4.gemfile | 5 ----- .../{upgrade.gemfile => sidekiq52_rails52.gemfile} | 0 gemfiles/sidekiq60_rails52.gemfile | 10 ++++++++++ 5 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 gemfiles/ruby20.gemfile delete mode 100644 gemfiles/sidekiq4.gemfile rename gemfiles/{upgrade.gemfile => sidekiq52_rails52.gemfile} (100%) create mode 100644 gemfiles/sidekiq60_rails52.gemfile diff --git a/.travis.yml b/.travis.yml index bb7ffad..4d2af35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,15 @@ language: ruby rvm: - 2.2 - 2.3 - - 2.4.1 - - 2.5.1 + - 2.4.9 + - 2.5.7 + - 2.6.5 - jruby - rbx-2 gemfile: - - gemfiles/ruby20.gemfile - - gemfiles/sidekiq4.gemfile - - gemfiles/upgrade.gemfile + - gemfiles/sidekiq52_rails52.gemfile + - gemfiles/sidekiq60_rails52.gemfile script: "bundle exec rspec spec" diff --git a/gemfiles/ruby20.gemfile b/gemfiles/ruby20.gemfile deleted file mode 100644 index efefa36..0000000 --- a/gemfiles/ruby20.gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source 'https://rubygems.org' - -gem 'sidekiq', '< 5' -gem 'nokogiri', '< 1.7' - -gemspec :path => '../' diff --git a/gemfiles/sidekiq4.gemfile b/gemfiles/sidekiq4.gemfile deleted file mode 100644 index ce408bd..0000000 --- a/gemfiles/sidekiq4.gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source 'https://rubygems.org' - -gem 'sidekiq', '< 5' - -gemspec :path => '../' diff --git a/gemfiles/upgrade.gemfile b/gemfiles/sidekiq52_rails52.gemfile similarity index 100% rename from gemfiles/upgrade.gemfile rename to gemfiles/sidekiq52_rails52.gemfile diff --git a/gemfiles/sidekiq60_rails52.gemfile b/gemfiles/sidekiq60_rails52.gemfile new file mode 100644 index 0000000..867f79d --- /dev/null +++ b/gemfiles/sidekiq60_rails52.gemfile @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +gem 'sidekiq', '~> 6.0' +gem 'nokogiri', '~> 1.8.5' +gem 'rspec-core', '~> 3.8' +gem 'activejob', '~> 5.2' +gem 'actionmailer', '~> 5.2' +gem 'activerecord', '~> 5.2' + +gemspec :path => '../' From 21c08629d0e29614fe89cea56ea390f42555dbcc Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Mon, 17 Feb 2020 09:16:49 +0100 Subject: [PATCH 5/9] Add the installation command for bundler 1.17.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4d2af35..0cc963c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ gemfile: script: "bundle exec rspec spec" before_install: - - gem install bundler + - gem install bundler:1.17.3 matrix: allow_failures: From a815a1dab315bb730a270482013da3d8714c8ef0 Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Mon, 17 Feb 2020 09:59:11 +0100 Subject: [PATCH 6/9] Fix GlobalID Configuration --- gemfiles/sidekiq52_rails52.gemfile | 2 ++ gemfiles/sidekiq60_rails52.gemfile | 2 ++ rspec-sidekiq.gemspec | 4 +++- spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb | 6 ++++-- spec/support/test_resource.rb | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/gemfiles/sidekiq52_rails52.gemfile b/gemfiles/sidekiq52_rails52.gemfile index 762a331..6717fd0 100644 --- a/gemfiles/sidekiq52_rails52.gemfile +++ b/gemfiles/sidekiq52_rails52.gemfile @@ -6,5 +6,7 @@ gem 'rspec-core', '~> 3.8' gem 'activejob', '~> 5.2' gem 'actionmailer', '~> 5.2' gem 'activerecord', '~> 5.2' +gem "activemodel", "~> 5.2" +gem "railties", "~> 5.2" gemspec :path => '../' diff --git a/gemfiles/sidekiq60_rails52.gemfile b/gemfiles/sidekiq60_rails52.gemfile index 867f79d..560e86c 100644 --- a/gemfiles/sidekiq60_rails52.gemfile +++ b/gemfiles/sidekiq60_rails52.gemfile @@ -6,5 +6,7 @@ gem 'rspec-core', '~> 3.8' gem 'activejob', '~> 5.2' gem 'actionmailer', '~> 5.2' gem 'activerecord', '~> 5.2' +gem "activemodel", "~> 5.2" +gem "railties", "~> 5.2" gemspec :path => '../' diff --git a/rspec-sidekiq.gemspec b/rspec-sidekiq.gemspec index f4bf5a3..8b22364 100644 --- a/rspec-sidekiq.gemspec +++ b/rspec-sidekiq.gemspec @@ -14,12 +14,14 @@ Gem::Specification.new do |s| s.add_dependency 'rspec-core', '~> 3.0', '>= 3.0.0' s.add_dependency 'sidekiq', '>= 2.4.0' - s.add_development_dependency 'rspec', '~> 3.0' + s.add_development_dependency 'rspec' s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8.0' s.add_development_dependency 'fuubar', '~> 2.0', '>= 2.0.0' s.add_development_dependency 'activejob', '~> 4.2', '>= 4.0.0' s.add_development_dependency 'actionmailer', '~> 4.2', '>= 4.0.0' s.add_development_dependency 'activerecord', '~> 4.2', '>= 4.0.0' + s.add_development_dependency 'activemodel', '~> 4.2', '>= 4.0.0' + s.add_development_dependency 'activesupport', '~> 4.2', '>= 4.0.0' s.files = Dir['.gitattributes'] + diff --git a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb index 46e750b..e8b7a58 100644 --- a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +++ b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb @@ -11,11 +11,13 @@ let(:resource) { TestResource.new } before(:each) do + GlobalID.app = 'rspec-sidekiq' worker.perform_async *worker_args active_job.perform_later 'someResource' active_job.perform_later(resource) TestActionMailer.testmail.deliver_later TestActionMailer.testmail(resource).deliver_later + GlobalID.app = "RSpec-Sidekiq" end describe 'expected usage' do @@ -73,11 +75,11 @@ end it 'matches on ActionMailer with a resource Job' do - expect(Sidekiq::Worker).to have_enqueued_sidekiq_job( + expect(Sidekiq::Worker).to have_enqueued_sidekiq_job([ 'TestActionMailer', 'testmail', 'deliver_now', - { '_aj_globalid' => resource.to_global_id.uri.to_s } + { '_aj_globalid' => resource.to_global_id.uri.to_s }] ) end end diff --git a/spec/support/test_resource.rb b/spec/support/test_resource.rb index 9107117..8055150 100644 --- a/spec/support/test_resource.rb +++ b/spec/support/test_resource.rb @@ -4,7 +4,7 @@ class TestResource attr_reader :global_id def initialize - @global_id = GlobalID.create(self, { app: 'rspec-sidekiq' }) + @global_id = GlobalID.create(self, app: 'rspec-sidekiq') end def self.find(id) From 720871d38448e43fe6237444021ea7e7f9d7a39c Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Thu, 20 Feb 2020 11:53:04 +0100 Subject: [PATCH 7/9] Resolve dependencies --- .travis.yml | 1 + gemfiles/sidekiq52_rails42.gemfile | 12 ++++++++++++ rspec-sidekiq.gemspec | 14 +++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 gemfiles/sidekiq52_rails42.gemfile diff --git a/.travis.yml b/.travis.yml index 0cc963c..0d20dc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ rvm: - rbx-2 gemfile: + - gemfiles/sidekiq52_rails42.gemfile - gemfiles/sidekiq52_rails52.gemfile - gemfiles/sidekiq60_rails52.gemfile diff --git a/gemfiles/sidekiq52_rails42.gemfile b/gemfiles/sidekiq52_rails42.gemfile new file mode 100644 index 0000000..cb8e3d1 --- /dev/null +++ b/gemfiles/sidekiq52_rails42.gemfile @@ -0,0 +1,12 @@ +source 'https://rubygems.org' + +gem 'sidekiq', '~> 5.2.2' +gem 'nokogiri', '~> 1.8.5' +gem 'rspec-core', '~> 3.8' +gem 'activejob', '~> 4.2' +gem 'actionmailer', '~> 4.2' +gem 'activerecord', '~> 4.2' +gem "activemodel", "~> 4.2" +gem "railties", "~> 4.2" + +gemspec :path => '../' \ No newline at end of file diff --git a/rspec-sidekiq.gemspec b/rspec-sidekiq.gemspec index 8b22364..44f71ed 100644 --- a/rspec-sidekiq.gemspec +++ b/rspec-sidekiq.gemspec @@ -15,13 +15,13 @@ Gem::Specification.new do |s| s.add_dependency 'sidekiq', '>= 2.4.0' s.add_development_dependency 'rspec' - s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8.0' - s.add_development_dependency 'fuubar', '~> 2.0', '>= 2.0.0' - s.add_development_dependency 'activejob', '~> 4.2', '>= 4.0.0' - s.add_development_dependency 'actionmailer', '~> 4.2', '>= 4.0.0' - s.add_development_dependency 'activerecord', '~> 4.2', '>= 4.0.0' - s.add_development_dependency 'activemodel', '~> 4.2', '>= 4.0.0' - s.add_development_dependency 'activesupport', '~> 4.2', '>= 4.0.0' + s.add_development_dependency 'coveralls' + s.add_development_dependency 'fuubar' + s.add_development_dependency 'activejob' + s.add_development_dependency 'actionmailer' + s.add_development_dependency 'activerecord' + s.add_development_dependency 'activemodel' + s.add_development_dependency 'activesupport' s.files = Dir['.gitattributes'] + From 3fc3b1c95820a4baf23dfc0966f428ee2795bad2 Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Fri, 21 Feb 2020 09:06:37 +0100 Subject: [PATCH 8/9] Removing Ruby < 2.4, as this is end of life and breaks the test-suite --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d20dc9..a22b063 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: ruby rvm: - - 2.2 - - 2.3 - - 2.4.9 - 2.5.7 - 2.6.5 - jruby From 89d837a8066aead14a8d4946f34dff7a85fb88d3 Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Thu, 30 Apr 2020 10:14:09 +0200 Subject: [PATCH 9/9] Implement pull request comments --- spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb | 5 ++--- spec/support/test_resource.rb | 8 +------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb index e8b7a58..dff4e93 100644 --- a/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +++ b/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb @@ -17,7 +17,6 @@ active_job.perform_later(resource) TestActionMailer.testmail.deliver_later TestActionMailer.testmail(resource).deliver_later - GlobalID.app = "RSpec-Sidekiq" end describe 'expected usage' do @@ -75,11 +74,11 @@ end it 'matches on ActionMailer with a resource Job' do - expect(Sidekiq::Worker).to have_enqueued_sidekiq_job([ + expect(Sidekiq::Worker).to have_enqueued_sidekiq_job( 'TestActionMailer', 'testmail', 'deliver_now', - { '_aj_globalid' => resource.to_global_id.uri.to_s }] + { '_aj_globalid' => resource.to_global_id.uri.to_s } ) end end diff --git a/spec/support/test_resource.rb b/spec/support/test_resource.rb index 8055150..1201821 100644 --- a/spec/support/test_resource.rb +++ b/spec/support/test_resource.rb @@ -1,16 +1,10 @@ class TestResource include GlobalID::Identification - attr_reader :global_id - - def initialize - @global_id = GlobalID.create(self, app: 'rspec-sidekiq') - end - def self.find(id) end def id - rand(36**10).to_s 36 + @id ||= rand(36**10).to_s 36 end end