diff --git a/lib/replay/event_declarations.rb b/lib/replay/event_declarations.rb index fe67b43..79c69de 100644 --- a/lib/replay/event_declarations.rb +++ b/lib/replay/event_declarations.rb @@ -22,7 +22,7 @@ def method_missing(name, *args) def declare_event(base, name, props) klass = Class.new do include Replay::EventDecorator - + attribute :published_at, Time, default: lambda{|p,a| Time.now} values do props.keys.each do |prop| attribute prop, props[prop] diff --git a/proofs/replay/publisher_proof.rb b/proofs/replay/publisher_proof.rb index f75b3e0..9987203 100644 --- a/proofs/replay/publisher_proof.rb +++ b/proofs/replay/publisher_proof.rb @@ -28,6 +28,11 @@ def pkey end module ReplayTest::Proof + def sets_publish_time + publish SomeEvent(pid: 123) + events.last.published_at != nil && (Time.now - events.last.published_at) < 20 + end + def defines_events? self.class.const_defined?(:SomeEvent) && self.class.const_get(:SomeEvent).is_a?(Class) end @@ -144,6 +149,11 @@ def published?; @published; end r.prove{ publish([]) == self} end +proof "sets the publish time on events" do + r = ReplayTest.new + r.prove{ sets_publish_time } +end + proof "Can implement initializer with arguments" do r = ReplayTest.new(:foo) r.prove { pkey == :foo }