reactor 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reactor/testing/matchers.rb +15 -24
- data/lib/reactor/version.rb +1 -1
- data/reactor.gemspec +2 -1
- data/spec/event_spec.rb +2 -2
- data/spec/models/concerns/publishable_spec.rb +14 -14
- data/spec/models/concerns/subscribable_spec.rb +1 -0
- data/spec/spec_helper.rb +5 -3
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7693ae6991c1cb79fa7257e131e844363db098fc
|
4
|
+
data.tar.gz: df0eac5e0c734cace8b3d37fa2be485f896ffc31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95f7c623e0569143793bc7ee1bd2870e5d71902ea794dd7f6aee6b0c95d67984f70b306ece0e1609f01f19ab0cb58b66f585dd557268a98e1c40d380b1113b36
|
7
|
+
data.tar.gz: 4bf1fe49637b5a72cdd5e774c42c2ba2e24b5567b6be195b0c11f5f9a0b36708ddd54f303a1e554250107f1bcd1ff700686888c66a0ac279da7cea6057530e3b
|
@@ -3,38 +3,29 @@ RSpec::Matchers.define :publish_event do |name, data = {}|
|
|
3
3
|
|
4
4
|
match do |block|
|
5
5
|
defaults = {:actor => anything}
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
rescue RSpec::Mocks::MockExpectationError => e
|
13
|
-
false
|
14
|
-
end
|
6
|
+
|
7
|
+
allow(Reactor::Event).to receive(:publish).with(name, a_hash_including(defaults.merge(data)))
|
8
|
+
|
9
|
+
block.call
|
10
|
+
|
11
|
+
expect(Reactor::Event).to have_received(:publish).with(name, a_hash_including(defaults.merge(data)))
|
15
12
|
end
|
16
13
|
end
|
17
14
|
|
18
|
-
RSpec::Matchers.define :publish_events do |*
|
15
|
+
RSpec::Matchers.define :publish_events do |*names|
|
19
16
|
supports_block_expectations
|
20
17
|
|
21
18
|
match do |block|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
expected = match.is_a?(Hash) ? match.values.first : {match => {}}
|
27
|
-
expected.each do |key, value|
|
28
|
-
expect(value).to eq(expected[key])
|
29
|
-
end
|
19
|
+
defaults = {:actor => anything}
|
20
|
+
|
21
|
+
names.each do |name|
|
22
|
+
allow(Reactor::Event).to receive(:publish).with(name, a_hash_including(defaults))
|
30
23
|
end
|
31
24
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
rescue RSpec::Mocks::MockExpectationError => e
|
37
|
-
false
|
25
|
+
block.call
|
26
|
+
|
27
|
+
names.each do |name|
|
28
|
+
expect(Reactor::Event).to have_received(:publish).with(name, a_hash_including(defaults))
|
38
29
|
end
|
39
30
|
end
|
40
31
|
end
|
data/lib/reactor/version.rb
CHANGED
data/reactor.gemspec
CHANGED
@@ -23,8 +23,9 @@ 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", "~>
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0.0"
|
27
27
|
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "pry-byebug"
|
28
29
|
spec.add_development_dependency "sqlite3"
|
29
30
|
spec.add_development_dependency "test_after_commit"
|
30
31
|
end
|
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.
|
21
|
+
expect(Reactor::Event).to receive(:perform_async).with(event_name, 'actor_id' => '1', 'event' => :user_did_this)
|
22
22
|
Reactor::Event.publish(:user_did_this, actor_id: '1')
|
23
23
|
end
|
24
24
|
end
|
@@ -51,7 +51,7 @@ describe Reactor::Event do
|
|
51
51
|
raise 'UNEXPECTED!'
|
52
52
|
end
|
53
53
|
Reactor::SUBSCRIBERS['barfed'] << Reactor::Subscribable::StaticSubscriberFactory.create('barfed') do |event|
|
54
|
-
|
54
|
+
mock.some_method
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -28,40 +28,39 @@ class TestSubscriber < Reactor::Subscriber
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe Reactor::Publishable do
|
31
|
-
before
|
31
|
+
before do
|
32
|
+
TestSubscriber.destroy_all
|
33
|
+
TestSubscriber.class_variable_set(:@@called, false)
|
34
|
+
end
|
35
|
+
|
32
36
|
describe 'publish' do
|
33
37
|
let(:pet) { Pet.create! }
|
34
38
|
let(:auction) { Auction.create!(pet: pet, start_at: DateTime.new(2012,12,21)) }
|
35
39
|
|
36
40
|
it 'publishes an event with actor_id and actor_type set as self' do
|
37
41
|
auction
|
38
|
-
expect(Reactor::Event).to receive(:publish)
|
39
|
-
expect(name).to eq(:an_event)
|
40
|
-
expect(data[:what]).to eq('the')
|
41
|
-
expect(data[:actor]).to eq(auction)
|
42
|
-
end
|
42
|
+
expect(Reactor::Event).to receive(:publish).with(:an_event, what: 'the', actor: auction)
|
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
|
-
|
48
|
-
expect(name).to eq(:woof)
|
49
|
-
expect(data[:actor]).to eq(pet)
|
50
|
-
end
|
47
|
+
allow(Reactor::Event).to receive(:publish).exactly(5).times
|
51
48
|
auction
|
49
|
+
expect(Reactor::Event).to have_received(:publish).with(:woof, a_hash_including(actor: pet, target: auction))
|
52
50
|
end
|
53
51
|
|
54
52
|
it 'reschedules an event when the :at time changes' do
|
55
53
|
start_at = auction.start_at
|
56
54
|
new_start_at = start_at + 1.week
|
57
55
|
expect(Reactor::Event).to receive(:reschedule).with :ring, anything
|
58
|
-
expect(Reactor::Event).to receive(:reschedule).with
|
59
|
-
|
56
|
+
expect(Reactor::Event).to receive(:reschedule).with(:begin,
|
57
|
+
a_hash_including(
|
60
58
|
at: new_start_at,
|
61
59
|
actor: auction,
|
62
60
|
was: start_at,
|
63
61
|
additional_info: 'curtis was here'
|
64
62
|
)
|
63
|
+
)
|
65
64
|
auction.start_at = new_start_at
|
66
65
|
auction.save!
|
67
66
|
end
|
@@ -71,12 +70,13 @@ describe Reactor::Publishable do
|
|
71
70
|
new_start_at = auction.start_at + 1.week
|
72
71
|
new_ring_time = new_start_at + 30.seconds
|
73
72
|
expect(Reactor::Event).to receive(:reschedule).with :begin, anything
|
74
|
-
expect(Reactor::Event).to receive(:reschedule).with
|
75
|
-
|
73
|
+
expect(Reactor::Event).to receive(:reschedule).with(:ring,
|
74
|
+
a_hash_including(
|
76
75
|
at: new_ring_time,
|
77
76
|
actor: auction,
|
78
77
|
was: ring_time
|
79
78
|
)
|
79
|
+
)
|
80
80
|
auction.start_at = new_start_at
|
81
81
|
auction.save!
|
82
82
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -27,8 +27,6 @@ end
|
|
27
27
|
RSpec.configure do |config|
|
28
28
|
# some (optional) config here
|
29
29
|
|
30
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
31
|
-
|
32
30
|
# Runs Sidekiq jobs inline by default unless the RSpec metadata :sidekiq is specified,
|
33
31
|
# in which case it will use the real Redis-backed Sidekiq queue
|
34
32
|
config.before(:each, :sidekiq) do
|
@@ -36,9 +34,13 @@ RSpec.configure do |config|
|
|
36
34
|
Sidekiq::Testing.disable!
|
37
35
|
end
|
38
36
|
|
39
|
-
|
40
37
|
config.after(:each, :sidekiq) do
|
41
38
|
Sidekiq::Testing.inline!
|
42
39
|
end
|
43
40
|
|
41
|
+
# Run specs in random order to surface order dependencies. If you find an
|
42
|
+
# order dependency and want to debug it, you can fix the order by providing
|
43
|
+
# the seed, which is printed after each run.
|
44
|
+
# --seed 1234
|
45
|
+
config.order = "random"
|
44
46
|
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.
|
4
|
+
version: 0.8.3
|
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-11-
|
14
|
+
date: 2014-11-13 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:
|
78
|
+
version: 3.0.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:
|
85
|
+
version: 3.0.0
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
87
|
name: pry
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,6 +97,20 @@ dependencies:
|
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: pry-byebug
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
type: :development
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
100
114
|
- !ruby/object:Gem::Dependency
|
101
115
|
name: sqlite3
|
102
116
|
requirement: !ruby/object:Gem::Requirement
|