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 119119
120120 if dereferenceable_subject ( 0 ) . respond_to? ( :add_observer )
121121
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+
122132 result = 'result'
133+ copier = proc { result }
123134 expect ( result ) . to receive ( :dup ) . at_least ( :once ) . and_return ( result )
124135 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 )
129137
130138 subject = dereferenceable_observable ( dup_on_deref : true , freeze_on_deref : true , copy_on_deref : copier )
131139
132140 subject . add_observer ( observer )
133141 execute_dereferenceable ( subject )
142+ latch . wait ( 1 )
134143 end
135144 end
136145end
You can’t perform that action at this time.
0 commit comments