File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 119
119
120
120
if dereferenceable_subject ( 0 ) . respond_to? ( :add_observer )
121
121
122
+ latch = Concurrent ::CountDownLatch . new
123
+ observer = Class . new do
124
+ def initialize ( latch )
125
+ @latch = latch
126
+ end
127
+ def update ( *args )
128
+ @latch . count_down
129
+ end
130
+ end . new ( latch )
131
+
122
132
result = 'result'
133
+ copier = proc { result }
123
134
expect ( result ) . to receive ( :dup ) . at_least ( :once ) . and_return ( result )
124
135
expect ( result ) . to receive ( :freeze ) . at_least ( :once ) . and_return ( result )
125
- copier = proc { result }
126
-
127
- observer = double ( 'observer' )
128
- expect ( observer ) . to receive ( :update ) . at_least ( :once ) . with ( any_args )
136
+ expect ( copier ) . to receive ( :call ) . at_least ( :once ) . and_return ( result )
129
137
130
138
subject = dereferenceable_observable ( dup_on_deref : true , freeze_on_deref : true , copy_on_deref : copier )
131
139
132
140
subject . add_observer ( observer )
133
141
execute_dereferenceable ( subject )
142
+ latch . wait ( 1 )
134
143
end
135
144
end
136
145
end
You can’t perform that action at this time.
0 commit comments