@@ -8,17 +8,18 @@ module RubyEventStore
8
8
module ActiveRecord
9
9
::RSpec . describe EventRepository do
10
10
helper = SpecHelper . new
11
- mk_repository = -> do
12
- serializer =
13
- case ENV [ "DATA_TYPE" ]
14
- when /json/
15
- JSON
16
- else
17
- RubyEventStore ::Serializers ::YAML
18
- end
19
- EventRepository . new ( serializer : serializer )
11
+
12
+ mk_serializer = -> do
13
+ case ENV [ "DATA_TYPE" ]
14
+ when /json/
15
+ JSON
16
+ else
17
+ RubyEventStore ::Serializers ::YAML
18
+ end
20
19
end
21
20
21
+ mk_repository = -> { EventRepository . new ( serializer : mk_serializer . call ) }
22
+
22
23
it_behaves_like "event repository" , mk_repository , helper
23
24
24
25
let ( :repository ) { mk_repository . call }
@@ -74,7 +75,7 @@ module ActiveRecord
74
75
end
75
76
76
77
specify "use default models" do
77
- repository = EventRepository . new ( serializer : Serializers :: YAML )
78
+ repository = EventRepository . new ( serializer : mk_serializer . call )
78
79
expect ( repository . instance_variable_get ( :@event_klass ) ) . to be ( Event )
79
80
expect ( repository . instance_variable_get ( :@stream_klass ) ) . to be ( EventInStream )
80
81
end
@@ -83,7 +84,7 @@ module ActiveRecord
83
84
repository =
84
85
EventRepository . new (
85
86
model_factory : WithAbstractBaseClass . new ( CustomApplicationRecord ) ,
86
- serializer : Serializers :: YAML ,
87
+ serializer : mk_serializer . call ,
87
88
)
88
89
expect ( repository . instance_variable_get ( :@event_klass ) . ancestors ) . to include ( CustomApplicationRecord )
89
90
expect ( repository . instance_variable_get ( :@stream_klass ) . ancestors ) . to include ( CustomApplicationRecord )
@@ -93,7 +94,7 @@ module ActiveRecord
93
94
repository =
94
95
EventRepository . new (
95
96
model_factory : WithAbstractBaseClass . new ( CustomApplicationRecord ) ,
96
- serializer : Serializers :: YAML ,
97
+ serializer : mk_serializer . call ,
97
98
)
98
99
repository . append_to_stream ( [ event = SRecord . new ] , Stream . new ( GLOBAL_STREAM ) , ExpectedVersion . any )
99
100
reader = SpecificationReader . new ( repository , Mappers ::Default . new )
0 commit comments