Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
135 additions
and
17 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 |
---|---|---|
|
@@ -21,3 +21,6 @@ tmp | |
*.o | ||
*.a | ||
mkmf.log | ||
.ruby-version | ||
.ruby-gemset | ||
.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 |
---|---|---|
@@ -1,11 +1,16 @@ | ||
language: ruby | ||
sudo: false | ||
cache: bundler | ||
script: bundle exec rspec | ||
bundler_args: --without=extras | ||
before_script: | ||
- bundle exec sidekiq -r ./spec/dummy_app/app.rb -L /tmp/sidekiq.log & | ||
- sleep 1 | ||
script: rspec spec | ||
bundler_args: --without=extras | ||
services: | ||
- redis-server | ||
rvm: | ||
- '2.4.0' | ||
- jruby-9.1.6.0 | ||
- 2.2.10 | ||
- 2.3.7 | ||
- 2.4.4 | ||
- 2.5.1 | ||
- jruby-9.1.17.0 |
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,10 @@ | ||
## [Unreleased] | ||
|
||
### Added | ||
- sidekiq 5 compatibility (closes [#11](https://github.com/krisleech/wisper-sidekiq/issues/11)) | ||
- support for optional `sidekiq_options` per subscriber class (closes [#15](https://github.com/krisleech/wisper-sidekiq/issues/15)) | ||
|
||
## [0.0.1] - 06-10-2014 | ||
|
||
### Added | ||
- Initial release |
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 |
---|---|---|
|
@@ -11,5 +11,5 @@ gem 'psych', platforms: :rbx | |
|
||
group :extras do | ||
gem 'rerun' | ||
gem 'pry' | ||
gem 'pry-byebug' | ||
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# This is loaded by Sidekiq | ||
|
||
require 'wisper/sidekiq' | ||
require_relative 'subscriber' |
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
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,60 @@ | ||
require 'wisper/sidekiq' | ||
|
||
RSpec.describe Wisper::SidekiqBroadcaster do | ||
class PublisherUnderTest | ||
include Wisper::Publisher | ||
|
||
def run | ||
broadcast(:it_happened) | ||
end | ||
end | ||
|
||
class RegularSubscriberUnderTest | ||
def self.it_happened(*_) | ||
end | ||
end | ||
|
||
class CustomizedSubscriberUnderTest | ||
def self.it_happened | ||
end | ||
|
||
def self.sidekiq_options | ||
{ queue: "my_queue" } | ||
end | ||
end | ||
|
||
let(:publisher) { PublisherUnderTest.new } | ||
|
||
before { Sidekiq::Testing.fake! } | ||
after { Sidekiq::Testing.disable! } | ||
|
||
describe '#broadcast' do | ||
it 'schedules a sidekiq job' do | ||
publisher.subscribe(RegularSubscriberUnderTest, async: described_class.new) | ||
|
||
expect { publisher.run } | ||
.to change(Sidekiq::Queues["default"], :size).by(1) | ||
end | ||
|
||
it 'can respect custom sidekiq_options' do | ||
publisher.subscribe(CustomizedSubscriberUnderTest, async: described_class.new) | ||
|
||
expect { publisher.run } | ||
.to change(Sidekiq::Queues["my_queue"], :size).by(1) | ||
end | ||
|
||
context 'when provides subscriber with args' do | ||
let(:subscriber) { RegularSubscriberUnderTest } | ||
let(:event) { 'it_happened' } | ||
let(:args) { [1,2,3] } | ||
|
||
subject(:broadcast_event) { described_class.new.broadcast(subscriber, nil, event, args) } | ||
|
||
it 'subscriber receives event with corrects args' do | ||
expect(RegularSubscriberUnderTest).to receive(event).with(*args) | ||
|
||
Sidekiq::Testing.inline! { broadcast_event } | ||
end | ||
end | ||
end | ||
end |