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.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.rvmrc +1 -1
  3. data/Gemfile +7 -3
  4. data/Guardfile +10 -0
  5. data/LICENSE +21 -0
  6. data/README.md +153 -0
  7. data/Rakefile +15 -0
  8. data/lib/replay.rb +39 -10
  9. data/lib/replay/backends.rb +50 -0
  10. data/lib/replay/event_declarations.rb +36 -0
  11. data/lib/replay/event_decorator.rb +13 -0
  12. data/lib/replay/events.rb +24 -0
  13. data/lib/replay/inflector.rb +55 -0
  14. data/lib/replay/observer.rb +18 -0
  15. data/lib/replay/publisher.rb +72 -0
  16. data/lib/replay/repository.rb +61 -0
  17. data/lib/replay/repository/configuration.rb +30 -0
  18. data/lib/replay/repository/identity_map.rb +25 -0
  19. data/lib/replay/router.rb +5 -0
  20. data/lib/replay/router/default_router.rb +21 -0
  21. data/lib/replay/rspec.rb +50 -0
  22. data/lib/replay/subscription_manager.rb +28 -0
  23. data/lib/replay/test.rb +64 -0
  24. data/lib/replay/test/test_event_stream.rb +19 -0
  25. data/lib/replay/version.rb +1 -1
  26. data/proofs/all.rb +7 -0
  27. data/proofs/proofs_init.rb +10 -0
  28. data/proofs/replay/inflector_proof.rb +32 -0
  29. data/proofs/replay/publisher_proof.rb +170 -0
  30. data/proofs/replay/repository_configuration_proof.rb +67 -0
  31. data/proofs/replay/repository_proof.rb +46 -0
  32. data/proofs/replay/subscriber_manager_proof.rb +39 -0
  33. data/proofs/replay/test_proof.rb +28 -0
  34. data/replay.gemspec +5 -4
  35. data/test/replay/observer_spec.rb +37 -0
  36. data/test/replay/router/default_router_spec.rb +43 -0
  37. data/test/test_helper.rb +10 -0
  38. metadata +65 -48
  39. data/README +0 -27
  40. data/lib/replay/active_record_event_store.rb +0 -32
  41. data/lib/replay/domain.rb +0 -33
  42. data/lib/replay/event.rb +0 -27
  43. data/lib/replay/event_store.rb +0 -55
  44. data/lib/replay/projector.rb +0 -19
  45. data/lib/replay/test_storage.rb +0 -8
  46. data/lib/replay/unknown_event_error.rb +0 -2
  47. data/test/spec_helper.rb +0 -6
  48. data/test/test_events.sqlite3 +0 -0
  49. data/test/unit/active_record_event_store_spec.rb +0 -24
  50. data/test/unit/domain_spec.rb +0 -53
  51. data/test/unit/event_spec.rb +0 -13
  52. data/test/unit/event_store_spec.rb +0 -28
  53. data/test/unit/projector_spec.rb +0 -19
@@ -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
-
@@ -1,13 +0,0 @@
1
- require './test/spec_helper'
2
-
3
- describe Replay::Event do
4
- before do
5
- @event = Replay::Event.new("shit_happened", :foo => :bar)
6
- end
7
-
8
- describe "method_missing" do
9
- it "fakes the reader" do
10
- @event.foo.must_equal :bar
11
- end
12
- end
13
- end
@@ -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
@@ -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