Skip to content

Commit

Permalink
Fix tests. Tests with latest sidekiq versions and ruby versions
Browse files Browse the repository at this point in the history
  • Loading branch information
simonoff committed Apr 27, 2015
1 parent 41a33e0 commit 7d53a1b
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Gemfile.lock
.ruby-version
.idea/
gemfiles/*.lock
*.sw?
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ language: ruby
services:
- redis-server
rvm:
- 1.9.3
- jruby-19mode
- rbx-19mode
- rbx2
- 2.0.0
- 2.1.0
- 2.2.1
gemfile:
- gemfiles/sidekiq_2.15.gemfile
- gemfiles/sidekiq_2.16.gemfile
- gemfiles/sidekiq_2.17.gemfile
- gemfiles/sidekiq_3.0.gemfile
- gemfiles/sidekiq_3.1.gemfile
- gemfiles/sidekiq_3.2.gemfile
- gemfiles/sidekiq_3.3.gemfile
- gemfiles/sidekiq_develop.gemfile
branches:
only:
Expand All @@ -22,4 +22,4 @@ notifications:
- [email protected]
matrix:
allow_failures:
- rvm: rbx-19mode
- rvm: rbx2
19 changes: 11 additions & 8 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
appraise "sidekiq-develop" do
gem 'sidekiq', github: 'mperham/sidekiq'
gem 'sidekiq', '3.0', :platform => :mri_19
end

appraise "sidekiq-2.17" do
gem 'sidekiq', '2.17'
gem 'sidekiq', '~> 2.17.0'
end

appraise "sidekiq-2.16" do
gem "sidekiq", '2.16'
appraise "sidekiq-3.0" do
gem "sidekiq", '~> 3.0.0'
end

appraise "sidekiq-2.15" do
gem "sidekiq", '2.15'
appraise "sidekiq-3.1" do
gem "sidekiq", '~> 3.1.0'
end

appraise "sidekiq-3.0" do
gem "sidekiq", '3.0'
appraise "sidekiq-3.2" do
gem "sidekiq", '~> 3.2.0'
end

appraise "sidekiq-3.3" do
gem "sidekiq", '~> 3.3.0'
end
2 changes: 1 addition & 1 deletion gemfiles/sidekiq_2.17.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source "http://rubygems.org"

gem "appraisal", "~> 1.0.0"
gem "pry", :platform => :mri
gem "sidekiq", "2.17"
gem "sidekiq", "~> 2.17.0"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/sidekiq_3.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source "http://rubygems.org"

gem "appraisal", "~> 1.0.0"
gem "pry", :platform => :mri
gem "sidekiq", "3.0"
gem "sidekiq", "~> 3.0.0"

gemspec :path => "../"
9 changes: 9 additions & 0 deletions gemfiles/sidekiq_3.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "appraisal", "~> 1.0.0"
gem "pry", :platform => :mri
gem "sidekiq", "~> 3.1.0"

gemspec :path => "../"
9 changes: 9 additions & 0 deletions gemfiles/sidekiq_3.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "appraisal", "~> 1.0.0"
gem "pry", :platform => :mri
gem "sidekiq", "~> 3.2.0"

gemspec :path => "../"
9 changes: 9 additions & 0 deletions gemfiles/sidekiq_3.3.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "appraisal", "~> 1.0.0"
gem "pry", :platform => :mri
gem "sidekiq", "~> 3.3.0"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/sidekiq_develop.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source "http://rubygems.org"

gem "appraisal", "~> 1.0.0"
gem "pry", :platform => :mri
gem "sidekiq", "3.0", :platform => :mri_19
gem "sidekiq", :github => "mperham/sidekiq"

gemspec :path => "../"
11 changes: 8 additions & 3 deletions spec/lib/sidekiq_testing_enabled_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@

describe 'When Sidekiq::Testing is enabled' do
describe 'when set to :fake!', sidekiq: :fake do

# Flush db before each test
before :each do
Sidekiq.redis(&:flushdb)
end
context 'with unique worker' do
it 'does not push duplicate messages' do
param = 'work'
expect(UniqueWorker.jobs.size).to eq(0)
UniqueWorker.perform_async(param)
expect(UniqueWorker.perform_async(param)).to_not be_nil
expect(UniqueWorker.jobs.size).to eq(1)
expect(UniqueWorker).to have_enqueued_job(param)
UniqueWorker.perform_async(param)
expect(UniqueWorker.perform_async(param)).to be_nil
expect(UniqueWorker.jobs.size).to eq(1)
end

it 'adds the unique_hash to the message' do
param = 'hash'
hash = SidekiqUniqueJobs::PayloadHelper.get_payload(UniqueWorker, :working, [param])
UniqueWorker.perform_async(param)
expect(UniqueWorker.perform_async(param)).to_not be_nil
expect(UniqueWorker.jobs.size).to eq(1)
expect(UniqueWorker.jobs.first['unique_hash']).to eq(hash)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

require 'sidekiq/redis_connection'
redis_url = ENV['REDIS_URL'] || 'redis://localhost/15'
REDIS = Sidekiq::RedisConnection.create(url: redis_url, namespace: 'testy')
REDIS = Sidekiq::RedisConnection.create(url: redis_url, namespace: 'sidekiq-unique-jobs-testing')

Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each { |f| require f }
RSpec.configure do |_config|
Expand Down

0 comments on commit 7d53a1b

Please sign in to comment.