replay 0.0.1 → 0.1.0
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 +7 -0
- data/.rvmrc +1 -1
- data/Gemfile +7 -3
- data/Guardfile +10 -0
- data/LICENSE +21 -0
- data/README.md +153 -0
- data/Rakefile +15 -0
- data/lib/replay.rb +39 -10
- data/lib/replay/backends.rb +50 -0
- data/lib/replay/event_declarations.rb +36 -0
- data/lib/replay/event_decorator.rb +13 -0
- data/lib/replay/events.rb +24 -0
- data/lib/replay/inflector.rb +55 -0
- data/lib/replay/observer.rb +18 -0
- data/lib/replay/publisher.rb +72 -0
- data/lib/replay/repository.rb +61 -0
- data/lib/replay/repository/configuration.rb +30 -0
- data/lib/replay/repository/identity_map.rb +25 -0
- data/lib/replay/router.rb +5 -0
- data/lib/replay/router/default_router.rb +21 -0
- data/lib/replay/rspec.rb +50 -0
- data/lib/replay/subscription_manager.rb +28 -0
- data/lib/replay/test.rb +64 -0
- data/lib/replay/test/test_event_stream.rb +19 -0
- data/lib/replay/version.rb +1 -1
- data/proofs/all.rb +7 -0
- data/proofs/proofs_init.rb +10 -0
- data/proofs/replay/inflector_proof.rb +32 -0
- data/proofs/replay/publisher_proof.rb +170 -0
- data/proofs/replay/repository_configuration_proof.rb +67 -0
- data/proofs/replay/repository_proof.rb +46 -0
- data/proofs/replay/subscriber_manager_proof.rb +39 -0
- data/proofs/replay/test_proof.rb +28 -0
- data/replay.gemspec +5 -4
- data/test/replay/observer_spec.rb +37 -0
- data/test/replay/router/default_router_spec.rb +43 -0
- data/test/test_helper.rb +10 -0
- metadata +65 -48
- data/README +0 -27
- data/lib/replay/active_record_event_store.rb +0 -32
- data/lib/replay/domain.rb +0 -33
- data/lib/replay/event.rb +0 -27
- data/lib/replay/event_store.rb +0 -55
- data/lib/replay/projector.rb +0 -19
- data/lib/replay/test_storage.rb +0 -8
- data/lib/replay/unknown_event_error.rb +0 -2
- data/test/spec_helper.rb +0 -6
- data/test/test_events.sqlite3 +0 -0
- data/test/unit/active_record_event_store_spec.rb +0 -24
- data/test/unit/domain_spec.rb +0 -53
- data/test/unit/event_spec.rb +0 -13
- data/test/unit/event_store_spec.rb +0 -28
- data/test/unit/projector_spec.rb +0 -19
data/test/unit/domain_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require './test/spec_helper'
|
2
|
-
|
3
|
-
describe Replay do
|
4
|
-
class ReplayTestClass
|
5
|
-
include Replay::Domain
|
6
|
-
|
7
|
-
attr_accessor :bar_value
|
8
|
-
|
9
|
-
def id
|
10
|
-
1
|
11
|
-
end
|
12
|
-
|
13
|
-
def foo
|
14
|
-
signal_event :foo_happened, "bar"
|
15
|
-
end
|
16
|
-
|
17
|
-
def bad_foo
|
18
|
-
signal_event :no_foo_lovey
|
19
|
-
end
|
20
|
-
|
21
|
-
apply :foo_happened do |what|
|
22
|
-
self.bar_value = what
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
before do
|
27
|
-
@something = ReplayTestClass.new
|
28
|
-
end
|
29
|
-
describe "behavior with signalling" do
|
30
|
-
it "raises an error for unknown events" do
|
31
|
-
lambda{@something.bad_foo}.must_raise UnknownEventError
|
32
|
-
end
|
33
|
-
|
34
|
-
it "sends the event to the EventStore" do
|
35
|
-
Replay::EventStore.expects(:handle_event).with(:foo_happened, 1, 'bar')
|
36
|
-
@something.foo
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "rebuilding" do
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "applying an event" do
|
45
|
-
it "changes state" do
|
46
|
-
@something.foo
|
47
|
-
@something.bar_value.must_equal "bar"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
data/test/unit/event_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require './test/spec_helper'
|
2
|
-
|
3
|
-
describe Replay::EventStore do
|
4
|
-
before do
|
5
|
-
Replay::EventStore.configure do |config|
|
6
|
-
config.storage = Replay::TestStorage.new
|
7
|
-
end
|
8
|
-
end
|
9
|
-
after do
|
10
|
-
Replay::EventStore.clear_listeners
|
11
|
-
end
|
12
|
-
describe "#handle_event" do
|
13
|
-
def action
|
14
|
-
Replay::EventStore.handle_event(:foo_event, 123, {:bar => "fly"})
|
15
|
-
end
|
16
|
-
it "stores the event" do
|
17
|
-
Replay::TestStorage.any_instance.expects(:store).with(:foo_event, 123, {:bar => "fly"} )
|
18
|
-
action
|
19
|
-
end
|
20
|
-
it "notifies listeners" do
|
21
|
-
listener = mock("listener") do
|
22
|
-
expects(:handle_event).with(:foo_event, 123, {:bar => 'fly'})
|
23
|
-
end
|
24
|
-
Replay::EventStore.add_listener(:foo_event, listener)
|
25
|
-
action
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/test/unit/projector_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require './test/spec_helper'
|
2
|
-
|
3
|
-
describe Replay::Projector do
|
4
|
-
after do
|
5
|
-
Replay::EventStore.clear_listeners
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#listen" do
|
9
|
-
it "adds the class as a listener to the EventStore" do
|
10
|
-
class ProjectorExample
|
11
|
-
Replay::EventStore.expects(:add_listener).with(:foo_happened, self)
|
12
|
-
|
13
|
-
include Replay::Projector
|
14
|
-
listen :foo_happened do |model_id, arg|
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|