-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mock_redis when testing in fake mode
- Loading branch information
Showing
16 changed files
with
230 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
Gemfile.lock | ||
|
||
.ruby-version | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--color | ||
--format progress | ||
--order random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
source 'http://rubygems.org' | ||
gemspec | ||
gemspec | ||
|
||
group :development do | ||
gem 'sidekiq', github: 'mperham/sidekiq' | ||
end | ||
|
||
gem 'pry' | ||
gem 'pry-stack_explorer' | ||
gem 'pry-debugger' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" | ||
require 'rake/testtask' | ||
Rake::TestTask.new(:test) do |test| | ||
test.libs << 'test' | ||
#SO MUCH NOISE | ||
#test.warning = true | ||
test.pattern = 'test/**/test_*.rb' | ||
end | ||
require 'rspec/core/rake_task' | ||
|
||
task :default => :test | ||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'mock_redis' | ||
module SidekiqUniqueJobs | ||
def self.redis_mock | ||
@redis_mock ||= MockRedis.new | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
require 'sidekiq/worker' | ||
require "sidekiq-unique-jobs" | ||
require 'sidekiq/scheduled' | ||
require 'sidekiq-unique-jobs/middleware/server/unique_jobs' | ||
|
||
describe "When Sidekiq::Testing is enabled" do | ||
describe 'when set to :fake!', sidekiq: :fake do | ||
context "with unique worker" do | ||
it "does not push duplicate messages" do | ||
param = 'work' | ||
expect(UniqueWorker).to have_enqueued_jobs(0) | ||
UniqueWorker.perform_async(param) | ||
expect(UniqueWorker).to have_enqueued_jobs(1) | ||
expect(UniqueWorker).to have_enqueued_job(param) | ||
UniqueWorker.perform_async(param) | ||
expect(UniqueWorker).to have_enqueued_jobs(1) | ||
end | ||
end | ||
|
||
context "with non-unique worker" do | ||
|
||
it "pushes duplicates messages" do | ||
param = 'work' | ||
expect(MyWorker).to have_enqueued_jobs(0) | ||
MyWorker.perform_async(param) | ||
expect(MyWorker).to have_enqueued_jobs(1) | ||
expect(MyWorker).to have_enqueued_job(param) | ||
MyWorker.perform_async(param) | ||
expect(MyWorker).to have_enqueued_jobs(2) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
7787ffc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. 👍