reactor 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48d54ad63bce2589fbe3d6e39d8d9fe7e2d1fca6
4
- data.tar.gz: 484fbf659d971b11479a0bd24392657ba4e9a031
3
+ metadata.gz: c458036301b887cea2e6e656cd94ed497750ebed
4
+ data.tar.gz: 706f502c1bbbac9172374b7b065ddb627f3de656
5
5
  SHA512:
6
- metadata.gz: 32f14db9aba4a493b5a8765cf8b7d1a50723cc585215a40e0cb5bd8b8369d504871ec0288232e3dd647eb50ae5521b89577123af8708cf03bb8df61b413da995
7
- data.tar.gz: 3c854cf77e8188db2598dba97e80cb40856fc3f70f497861508c99447147e1743840d7cc06c9c1997c87f6baa6a360d56257ae8a57b8074d96a65591f3e1b2a1
6
+ metadata.gz: 1b5ebaf7f01782274bbd324789f138e6fc82af0de759d624d63e6c50f553783ff4be37b774d365086984e64ef11367777d4f98f108533a6b1ebc3a6532d64c65
7
+ data.tar.gz: e0f664ec820fcaa59c7a181bceffdb3b049799f841ccced731392e21b1e6453bacfafc2460b3010fca64ae083d17fcd0ae674484c0c955ecb5f208399c4d6487
data/lib/reactor/event.rb CHANGED
@@ -64,9 +64,9 @@ class Reactor::Event
64
64
 
65
65
  def enforce_serializable_model_keys!(event_signature)
66
66
  event_signature = event_signature.stringify_keys
67
- serializable_models = event_signature.keys.map(&:to_s).select { |k| k.include?('_id') || k.include?('_type') }
68
- .map { |k| k.gsub('_id', '') }
69
- .map { |k| k.gsub('_type', '') }
67
+ serializable_models = event_signature.keys.map(&:to_s).select { |k| k.end_with?('_id') || k.end_with?('_type') }
68
+ .map { |k| k.gsub(/_id\Z/, '') }
69
+ .map { |k| k.gsub(/_type\Z/, '') }
70
70
  .uniq
71
71
 
72
72
  serializable_models.each do |model_relation_name|
@@ -1,7 +1,9 @@
1
1
  RSpec::Matchers.define :publish_event do |name, data = {}|
2
+ supports_block_expectations
3
+
2
4
  match do |block|
3
5
  defaults = {:actor => anything}
4
- Reactor::Event.should_receive(:publish).with(name, hash_including(defaults.merge(data)))
6
+ expect(Reactor::Event).to receive(:publish).with(name, hash_including(defaults.merge(data)))
5
7
 
6
8
  begin
7
9
  block.call
@@ -14,14 +16,16 @@ RSpec::Matchers.define :publish_event do |name, data = {}|
14
16
  end
15
17
 
16
18
  RSpec::Matchers.define :publish_events do |*events|
19
+ supports_block_expectations
20
+
17
21
  match do |block|
18
- Reactor::Event.should_receive(:publish).exactly(events.count).times.with do |event, data|
22
+ expect(Reactor::Event).to receive(:publish).exactly(events.count).times do |event, data|
19
23
  match = events.select { |e| (e.is_a?(Hash) ? e.keys.first : e) == event }.first
20
- match.should be_present
24
+ expect(match).to be_present
21
25
 
22
26
  expected = match.is_a?(Hash) ? match.values.first : {match => {}}
23
27
  expected.each do |key, value|
24
- value.should == expected[key]
28
+ expect(value).to eq(expected[key])
25
29
  end
26
30
  end
27
31
 
@@ -36,8 +40,10 @@ RSpec::Matchers.define :publish_events do |*events|
36
40
  end
37
41
 
38
42
  RSpec::Matchers.define :subscribe_to do |name, data = {}, &expectations|
43
+ supports_block_expectations
44
+
39
45
  match do
40
46
  expectations.call if expectations.present?
41
47
  Reactor::Event.publish(name, data)
42
48
  end
43
- end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module Reactor
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
data/reactor.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rspec", "~> 2.14.1"
26
+ spec.add_development_dependency "rspec", "~> 2.99.0"
27
27
  spec.add_development_dependency "pry"
28
28
  spec.add_development_dependency "sqlite3"
29
29
  spec.add_development_dependency "test_after_commit"
@@ -30,7 +30,7 @@ describe Reactor::ResourceActionable do
30
30
 
31
31
  describe "when action strategy class exists" do
32
32
  it 'runs the strategy of the matching name' do
33
- Reactor::ResourceActionable::CreateEvent.should_receive(:perform_on).with(controller_stub)
33
+ expect(Reactor::ResourceActionable::CreateEvent).to receive(:perform_on).with(controller_stub)
34
34
  controller_stub.create
35
35
  end
36
36
  end
@@ -38,7 +38,7 @@ describe Reactor::ResourceActionable do
38
38
  describe "when action is non-standard rails CRUD action" do
39
39
  it 'fires a basic action_event' do
40
40
  controller_stub.action_name = 'do_thing'
41
- controller_stub.should_receive(:action_event).with("cat_do_thing")
41
+ expect(controller_stub).to receive(:action_event).with("cat_do_thing")
42
42
  controller_stub.create
43
43
  end
44
44
  end
@@ -47,41 +47,41 @@ end
47
47
  describe "ActionEvents" do
48
48
  let(:actionable_resource) { ArbitraryModel.create! }
49
49
  let(:nested_resource) { Pet.create! }
50
- let(:ctrl_stub) { stub(resource_name: "cat", actionable_resource: actionable_resource, nested_resource: nested_resource, params: {'cat' => {name: "Sasha"}} ) }
50
+ let(:ctrl_stub) { double(resource_name: "cat", actionable_resource: actionable_resource, nested_resource: nested_resource, params: {'cat' => {name: "Sasha"}} ) }
51
51
 
52
52
  describe "ShowEvent" do
53
53
  after { Reactor::ResourceActionable::ShowEvent.perform_on(ctrl_stub) }
54
- specify { ctrl_stub.should_receive(:action_event).with("cat_viewed", target: actionable_resource) }
54
+ specify { expect(ctrl_stub).to receive(:action_event).with("cat_viewed", target: actionable_resource) }
55
55
  end
56
56
 
57
57
  describe "EditEvent" do
58
58
  after { Reactor::ResourceActionable::EditEvent.perform_on(ctrl_stub) }
59
- specify { ctrl_stub.should_receive(:action_event).with("edit_cat_form_viewed", target: actionable_resource) }
59
+ specify { expect(ctrl_stub).to receive(:action_event).with("edit_cat_form_viewed", target: actionable_resource) }
60
60
  end
61
61
 
62
62
  describe "NewEvent" do
63
63
  after { Reactor::ResourceActionable::NewEvent.perform_on(ctrl_stub) }
64
- specify { ctrl_stub.should_receive(:action_event).with("new_cat_form_viewed", target: nested_resource) }
64
+ specify { expect(ctrl_stub).to receive(:action_event).with("new_cat_form_viewed", target: nested_resource) }
65
65
  end
66
66
 
67
67
  describe "IndexEvent" do
68
68
  after { Reactor::ResourceActionable::IndexEvent.perform_on(ctrl_stub) }
69
- specify { ctrl_stub.should_receive(:action_event).with("cats_indexed", target: nested_resource) }
69
+ specify { expect(ctrl_stub).to receive(:action_event).with("cats_indexed", target: nested_resource) }
70
70
  end
71
71
 
72
72
  describe "DestroyEvent" do
73
73
  after { Reactor::ResourceActionable::DestroyEvent.perform_on(ctrl_stub) }
74
- specify { ctrl_stub.should_receive(:action_event).with("cat_destroyed", last_snapshot: actionable_resource.as_json) }
74
+ specify { expect(ctrl_stub).to receive(:action_event).with("cat_destroyed", last_snapshot: actionable_resource.as_json) }
75
75
  end
76
76
 
77
77
  describe "CreateEvent" do
78
78
  after { Reactor::ResourceActionable::CreateEvent.perform_on(ctrl_stub) }
79
79
 
80
80
  describe "when resource is valid" do
81
- before { actionable_resource.should_receive(:valid?).and_return(true) }
81
+ before { expect(actionable_resource).to receive(:valid?).and_return(true) }
82
82
 
83
83
  specify do
84
- ctrl_stub.should_receive(:action_event)
84
+ expect(ctrl_stub).to receive(:action_event)
85
85
  .with("cat_created",
86
86
  target: actionable_resource,
87
87
  attributes: {name: "Sasha"})
@@ -90,12 +90,12 @@ describe "ActionEvents" do
90
90
 
91
91
  describe "when resource is not valid" do
92
92
  before do
93
- actionable_resource.should_receive(:valid?).and_return(false)
94
- actionable_resource.should_receive(:errors).and_return('awesomeness' => 'too awesome')
93
+ expect(actionable_resource).to receive(:valid?).and_return(false)
94
+ expect(actionable_resource).to receive(:errors).and_return('awesomeness' => 'too awesome')
95
95
  end
96
96
 
97
97
  specify do
98
- ctrl_stub.should_receive(:action_event)
98
+ expect(ctrl_stub).to receive(:action_event)
99
99
  .with("cat_create_failed",
100
100
  errors: {'awesomeness' => 'too awesome'},
101
101
  target: nested_resource,
@@ -109,12 +109,12 @@ describe "ActionEvents" do
109
109
 
110
110
  describe "when resource is valid" do
111
111
  before do
112
- actionable_resource.should_receive(:valid?).and_return(true)
113
- actionable_resource.should_receive(:previous_changes).and_return({'name' => [nil, "Sasha"]})
112
+ expect(actionable_resource).to receive(:valid?).and_return(true)
113
+ expect(actionable_resource).to receive(:previous_changes).and_return({'name' => [nil, "Sasha"]})
114
114
  end
115
115
 
116
116
  specify do
117
- ctrl_stub.should_receive(:action_event)
117
+ expect(ctrl_stub).to receive(:action_event)
118
118
  .with("cat_updated",
119
119
  target: actionable_resource,
120
120
  changes: {'name' => [nil, "Sasha"]})
@@ -123,12 +123,12 @@ describe "ActionEvents" do
123
123
 
124
124
  describe "when resource is not valid" do
125
125
  before do
126
- actionable_resource.should_receive(:valid?).and_return(false)
127
- actionable_resource.should_receive(:errors).and_return('awesomeness' => 'too awesome')
126
+ expect(actionable_resource).to receive(:valid?).and_return(false)
127
+ expect(actionable_resource).to receive(:errors).and_return('awesomeness' => 'too awesome')
128
128
  end
129
129
 
130
130
  specify do
131
- ctrl_stub.should_receive(:action_event)
131
+ expect(ctrl_stub).to receive(:action_event)
132
132
  .with("cat_update_failed",
133
133
  target: actionable_resource,
134
134
  errors: {'awesomeness' => 'too awesome'},
data/spec/event_spec.rb CHANGED
@@ -18,7 +18,7 @@ describe Reactor::Event do
18
18
 
19
19
  describe 'publish' do
20
20
  it 'fires the first perform and sets message event_id' do
21
- Reactor::Event.should_receive(:perform_async).with(event_name, 'actor_id' => '1', 'actor_type' => 'Pet', 'event' => :user_did_this)
21
+ expect(Reactor::Event).to receive(:perform_async).with(event_name, 'actor_id' => '1', 'actor_type' => 'Pet', 'event' => :user_did_this)
22
22
  Reactor::Event.publish(:user_did_this, actor_id: '1', actor_type: 'Pet')
23
23
  end
24
24
 
@@ -39,22 +39,22 @@ describe Reactor::Event do
39
39
  before { Reactor::Subscriber.create(event_name: :user_did_this) }
40
40
  after { Reactor::Subscriber.destroy_all }
41
41
  it 'fires all subscribers' do
42
- Reactor::Subscriber.any_instance.should_receive(:fire).with(hash_including(actor_id: '1'))
42
+ expect_any_instance_of(Reactor::Subscriber).to receive(:fire).with(hash_including(actor_id: '1'))
43
43
  Reactor::Event.perform(event_name, actor_id: '1')
44
44
  end
45
45
 
46
46
  it 'sets a fired_at key in event data' do
47
- Reactor::Subscriber.any_instance.should_receive(:fire).with(hash_including(fired_at: anything))
47
+ expect_any_instance_of(Reactor::Subscriber).to receive(:fire).with(hash_including(fired_at: anything))
48
48
  Reactor::Event.perform(event_name, actor_id: '1')
49
49
  end
50
50
 
51
51
  it 'works with the legacy .process method, too' do
52
- Reactor::Subscriber.any_instance.should_receive(:fire).with(hash_including(actor_id: '1'))
52
+ expect_any_instance_of(Reactor::Subscriber).to receive(:fire).with(hash_including(actor_id: '1'))
53
53
  Reactor::Event.perform(event_name, actor_id: '1')
54
54
  end
55
55
 
56
56
  describe 'when subscriber throws exception', :sidekiq do
57
- let(:mock) { mock(:thing, some_method: 3) }
57
+ let(:mock) { double(:thing, some_method: 3) }
58
58
  let(:barfing_event) { Reactor::Event.perform('barfed', somethin: 'up') }
59
59
 
60
60
  before do
@@ -63,7 +63,7 @@ describe Reactor::Event do
63
63
  raise 'UNEXPECTED!'
64
64
  end
65
65
  Reactor::SUBSCRIBERS['barfed'] << Reactor::Subscribable::StaticSubscriberFactory.create('barfed') do |event|
66
- mock.some_method
66
+ double.some_method
67
67
  end
68
68
  end
69
69
 
@@ -80,12 +80,12 @@ describe Reactor::Event do
80
80
  it 'can schedule and reschedule an event in the future' do
81
81
  expect {
82
82
  jid = Reactor::Event.publish :turtle_time, at: time
83
- scheduled.find_job(jid).score.should == time.to_f
83
+ expect(scheduled.find_job(jid).score).to eq(time.to_f)
84
84
  }.to change { scheduled.size }.by(1)
85
85
 
86
86
  expect {
87
87
  jid = Reactor::Event.reschedule :turtle_time, at: (time + 2.hours), was: time
88
- scheduled.find_job(jid).score.should == (time + 2.hours).to_f
88
+ expect(scheduled.find_job(jid).score).to eq((time + 2.hours).to_f)
89
89
  }.to_not change { scheduled.size }
90
90
  end
91
91
  end
@@ -101,19 +101,32 @@ describe Reactor::Event do
101
101
 
102
102
  describe 'getters' do
103
103
  context 'basic key value' do
104
- its(:random) { should == 'data' }
104
+ describe '#random' do
105
+ subject { super().random }
106
+ it { is_expected.to eq('data') }
107
+ end
105
108
  end
106
109
 
107
110
  context 'foreign key and foreign type' do
108
- its(:pet) { should be_a MyModule::Cat }
109
- its('pet.id') { should == MyModule::Cat.last.id }
111
+ describe '#pet' do
112
+ subject { super().pet }
113
+ it { is_expected.to be_a MyModule::Cat }
114
+ end
115
+
116
+ describe '#pet' do
117
+ subject { super().pet }
118
+ describe '#id' do
119
+ subject { super().id }
120
+ it { is_expected.to eq(MyModule::Cat.last.id) }
121
+ end
122
+ end
110
123
  end
111
124
  end
112
125
 
113
126
  describe 'setters' do
114
127
  it 'sets simple keys' do
115
128
  event.simple = 'key'
116
- event.data[:simple].should == 'key'
129
+ expect(event.data[:simple]).to eq('key')
117
130
  end
118
131
 
119
132
  it 'sets active_record polymorphic keys' do
@@ -126,14 +139,14 @@ describe Reactor::Event do
126
139
 
127
140
  describe 'data' do
128
141
  let(:serialized_event) { event.data }
129
- specify { serialized_event.should be_a Hash }
130
- specify { serialized_event[:random].should == 'data' }
142
+ specify { expect(serialized_event).to be_a Hash }
143
+ specify { expect(serialized_event[:random]).to eq('data') }
131
144
  end
132
145
 
133
146
  describe 'new' do
134
- specify { event.should be_a Reactor::Event }
135
- specify { event.pet_id.should == cat.id }
136
- specify { event.arbitrary_model_id.should == arbitrary_model.id }
147
+ specify { expect(event).to be_a Reactor::Event }
148
+ specify { expect(event.pet_id).to eq(cat.id) }
149
+ specify { expect(event.arbitrary_model_id).to eq(arbitrary_model.id) }
137
150
  end
138
151
  end
139
152
  end
@@ -35,18 +35,18 @@ describe Reactor::Publishable do
35
35
 
36
36
  it 'publishes an event with actor_id and actor_type set as self' do
37
37
  auction
38
- Reactor::Event.should_receive(:publish) do |name, data|
39
- name.should == :an_event
40
- data[:what].should == 'the'
41
- data[:actor].should == auction
38
+ expect(Reactor::Event).to receive(:publish) do |name, data|
39
+ expect(name).to eq(:an_event)
40
+ expect(data[:what]).to eq('the')
41
+ expect(data[:actor]).to eq(auction)
42
42
  end
43
43
  auction.publish(:an_event, {what: 'the'})
44
44
  end
45
45
 
46
46
  it 'publishes an event with provided actor and target methods' do
47
- Reactor::Event.should_receive(:publish) do |name, data|
48
- name.should == :woof
49
- data[:actor].should == pet
47
+ expect(Reactor::Event).to receive(:publish) do |name, data|
48
+ expect(name).to eq(:woof)
49
+ expect(data[:actor]).to eq(pet)
50
50
  end
51
51
  auction
52
52
  end
@@ -54,8 +54,8 @@ describe Reactor::Publishable do
54
54
  it 'reschedules an event when the :at time changes' do
55
55
  start_at = auction.start_at
56
56
  new_start_at = start_at + 1.week
57
- Reactor::Event.should_receive(:reschedule).with :ring, anything
58
- Reactor::Event.should_receive(:reschedule).with :begin,
57
+ expect(Reactor::Event).to receive(:reschedule).with :ring, anything
58
+ expect(Reactor::Event).to receive(:reschedule).with :begin,
59
59
  hash_including(
60
60
  at: new_start_at,
61
61
  actor: auction,
@@ -70,8 +70,8 @@ describe Reactor::Publishable do
70
70
  ring_time = auction.ring_timeout
71
71
  new_start_at = auction.start_at + 1.week
72
72
  new_ring_time = new_start_at + 30.seconds
73
- Reactor::Event.should_receive(:reschedule).with :begin, anything
74
- Reactor::Event.should_receive(:reschedule).with :ring,
73
+ expect(Reactor::Event).to receive(:reschedule).with :begin, anything
74
+ expect(Reactor::Event).to receive(:reschedule).with :ring,
75
75
  hash_including(
76
76
  at: new_ring_time,
77
77
  actor: auction,
@@ -84,24 +84,24 @@ describe Reactor::Publishable do
84
84
  it 'supports immediate events (on create) that get fired once' do
85
85
  TestSubscriber.create! event_name: :bell
86
86
  auction
87
- TestSubscriber.class_variable_get(:@@called).should be_true
87
+ expect(TestSubscriber.class_variable_get(:@@called)).to be_truthy
88
88
  TestSubscriber.class_variable_set(:@@called, false)
89
89
  auction.start_at = 1.day.from_now
90
90
  auction.save
91
- TestSubscriber.class_variable_get(:@@called).should be_false
91
+ expect(TestSubscriber.class_variable_get(:@@called)).to be_falsey
92
92
  end
93
93
 
94
94
  it 'does not publish an event scheduled for the past' do
95
95
  TestSubscriber.create! event_name: :begin
96
96
  auction
97
- TestSubscriber.class_variable_get(:@@called).should be_false
97
+ expect(TestSubscriber.class_variable_get(:@@called)).to be_falsey
98
98
  end
99
99
 
100
100
  it 'does publish an event scheduled for the future' do
101
101
  TestSubscriber.create! event_name: :begin
102
102
  Auction.create!(pet: pet, start_at: Time.current + 1.week)
103
103
 
104
- TestSubscriber.class_variable_get(:@@called).should be_true
104
+ expect(TestSubscriber.class_variable_get(:@@called)).to be_truthy
105
105
  end
106
106
 
107
107
  it 'can fire events onsave for any condition' do
@@ -110,11 +110,11 @@ describe Reactor::Publishable do
110
110
  TestSubscriber.class_variable_set(:@@called, false)
111
111
  auction.start_at = 1.day.from_now
112
112
  auction.save
113
- TestSubscriber.class_variable_get(:@@called).should be_false
113
+ expect(TestSubscriber.class_variable_get(:@@called)).to be_falsey
114
114
  auction.start_at = 2.days.from_now
115
115
  auction.we_want_it = true
116
116
  auction.save
117
- TestSubscriber.class_variable_get(:@@called).should be_true
117
+ expect(TestSubscriber.class_variable_get(:@@called)).to be_truthy
118
118
  end
119
119
  end
120
120
  end
@@ -33,7 +33,7 @@ describe Reactor::Subscribable do
33
33
 
34
34
  describe 'on_event' do
35
35
  it 'binds block of code statically to event being fired' do
36
- Auction.any_instance.should_receive(:update_column).with(:status, 'first_bid_made')
36
+ expect_any_instance_of(Auction).to receive(:update_column).with(:status, 'first_bid_made')
37
37
  Reactor::Event.publish(:bid_made, target: Auction.create)
38
38
  end
39
39
 
@@ -46,49 +46,49 @@ describe Reactor::Subscribable do
46
46
 
47
47
  describe 'binding symbol of class method' do
48
48
  it 'fires on event' do
49
- Auction.should_receive(:ring_bell)
49
+ expect(Auction).to receive(:ring_bell)
50
50
  Reactor::Event.publish(:puppy_delivered)
51
51
  end
52
52
 
53
53
  it 'can be delayed' do
54
- Auction.should_receive(:pick_up_poop)
55
- Auction.should_receive(:delay_for).with(5.minutes).and_return(Auction)
54
+ expect(Auction).to receive(:pick_up_poop)
55
+ expect(Auction).to receive(:delay_for).with(5.minutes).and_return(Auction)
56
56
  Reactor::Event.perform('pooped', {})
57
57
  end
58
58
  end
59
59
 
60
60
  it 'binds proc' do
61
- Auction.should_receive(:puppies!)
61
+ expect(Auction).to receive(:puppies!)
62
62
  Reactor::Event.publish(:any_event)
63
63
  end
64
64
 
65
65
  it 'accepts wildcard event name' do
66
- Auction.any_instance.should_receive(:more_puppies!)
66
+ expect_any_instance_of(Auction).to receive(:more_puppies!)
67
67
  Reactor::Event.publish(:another_event, actor: Auction.create)
68
68
  end
69
69
 
70
70
  describe 'in_memory flag' do
71
71
  it 'doesnt fire perform_async when true' do
72
- Auction.should_receive(:puppies!)
73
- Reactor::StaticSubscribers::CatDeliveredHandler0.should_not_receive(:perform_async)
72
+ expect(Auction).to receive(:puppies!)
73
+ expect(Reactor::StaticSubscribers::CatDeliveredHandler0).not_to receive(:perform_async)
74
74
  Reactor::Event.publish(:cat_delivered)
75
75
  end
76
76
 
77
77
  it 'fires perform_async when falsey' do
78
- Reactor::StaticSubscribers::WildcardHandler0.should_receive(:perform_async)
78
+ expect(Reactor::StaticSubscribers::WildcardHandler0).to receive(:perform_async)
79
79
  Reactor::Event.publish(:puppy_delivered)
80
80
  end
81
81
  end
82
82
 
83
83
  describe '#perform' do
84
84
  it 'returns :__perform_aborted__ when Reactor is in test mode' do
85
- Reactor::StaticSubscribers::TestPuppyDeliveredHandler0.new.perform({}).should == :__perform_aborted__
85
+ expect(Reactor::StaticSubscribers::TestPuppyDeliveredHandler0.new.perform({})).to eq(:__perform_aborted__)
86
86
  Reactor::Event.publish(:test_puppy_delivered)
87
87
  end
88
88
 
89
89
  it 'performs normally when specifically enabled' do
90
90
  Reactor.enable_test_mode_subscriber(TestModeAuction)
91
- Reactor::StaticSubscribers::TestPuppyDeliveredHandler0.new.perform({}).should_not == :__perform_aborted__
91
+ expect(Reactor::StaticSubscribers::TestPuppyDeliveredHandler0.new.perform({})).not_to eq(:__perform_aborted__)
92
92
  Reactor::Event.publish(:test_puppy_delivered)
93
93
  end
94
94
  end
@@ -13,11 +13,21 @@ describe Reactor::Subscriber do
13
13
  describe 'fire' do
14
14
  subject { MySubscriber.create(event_name: :you_name_it).fire some: 'random', event: 'data' }
15
15
 
16
- its(:event) { should be_a Reactor::Event }
17
- its('event.some') { should == 'random' }
16
+ describe '#event' do
17
+ subject { super().event }
18
+ it { is_expected.to be_a Reactor::Event }
19
+ end
20
+
21
+ describe '#event' do
22
+ subject { super().event }
23
+ describe '#some' do
24
+ subject { super().some }
25
+ it { is_expected.to eq('random') }
26
+ end
27
+ end
18
28
 
19
29
  it 'executes block given' do
20
- subject.was_called.should be_true
30
+ expect(subject.was_called).to be_truthy
21
31
  end
22
32
  end
23
33
 
@@ -25,7 +35,7 @@ describe Reactor::Subscriber do
25
35
  describe 'matcher' do
26
36
  it 'can be set to star to bind to all events' do
27
37
  MySubscriber.create!(event_name: '*')
28
- MySubscriber.any_instance.should_receive(:fire).with(hash_including('random' => 'data', 'event' => 'this_event'))
38
+ expect_any_instance_of(MySubscriber).to receive(:fire).with(hash_including('random' => 'data', 'event' => 'this_event'))
29
39
  Reactor::Event.publish(:this_event, {random: 'data'})
30
40
  end
31
41
  end
data/spec/reactor_spec.rb CHANGED
@@ -12,9 +12,9 @@ describe Reactor do
12
12
 
13
13
  describe '.test_mode!' do
14
14
  it 'sets Reactor into test mode' do
15
- Reactor.test_mode?.should be_false
15
+ expect(Reactor.test_mode?).to be_falsey
16
16
  Reactor.test_mode!
17
- Reactor.test_mode?.should be_true
17
+ expect(Reactor.test_mode?).to be_truthy
18
18
  end
19
19
  end
20
20
 
@@ -23,13 +23,13 @@ describe Reactor do
23
23
  after { Reactor.disable_test_mode! }
24
24
 
25
25
  it 'subscribers created in test mode are disabled' do
26
- subscriber.should_not_receive :spy_on_me
26
+ expect(subscriber).not_to receive :spy_on_me
27
27
  Reactor::Event.publish :test_event
28
28
  end
29
29
 
30
30
  describe '.with_subscriber_enabled' do
31
31
  it 'enables a subscriber during test mode' do
32
- subscriber.should_receive :spy_on_me
32
+ expect(subscriber).to receive :spy_on_me
33
33
  Reactor.with_subscriber_enabled(subscriber) do
34
34
  Reactor::Event.publish :test_event
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - winfred
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-07-08 00:00:00.000000000 Z
14
+ date: 2014-11-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sidekiq
@@ -75,14 +75,14 @@ dependencies:
75
75
  requirements:
76
76
  - - "~>"
77
77
  - !ruby/object:Gem::Version
78
- version: 2.14.1
78
+ version: 2.99.0
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - "~>"
84
84
  - !ruby/object:Gem::Version
85
- version: 2.14.1
85
+ version: 2.99.0
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: pry
88
88
  requirement: !ruby/object:Gem::Requirement