@@ -24,19 +24,50 @@ def wash_hand
2424 include React ::Callbacks
2525 define_callback :before_dinner
2626
27- before_dinner :wash_hand , :turn_of_laptop
27+ before_dinner :wash_hand , :turn_off_laptop
2828
2929 def wash_hand ; end
3030
31- def turn_of_laptop ; end
31+ def turn_off_laptop ; end
3232 end
3333
3434 instance = Foo . new
3535 expect ( instance ) . to receive ( :wash_hand )
36- expect ( instance ) . to receive ( :turn_of_laptop )
36+ expect ( instance ) . to receive ( :turn_off_laptop )
3737 instance . run_callback ( :before_dinner )
3838 end
3939
40+ context 'using Hyperloop::Context.reset!' do
41+ after ( :all ) do
42+ Hyperloop ::Context . instance_variable_set ( :@context , nil )
43+ end
44+ it 'clears callbacks on Hyperloop::Context.reset!' do
45+ Hyperloop ::Context . reset!
46+ stub_const 'Foo' , Class . new
47+ Foo . class_eval do
48+ include React ::Callbacks
49+ define_callback :before_dinner
50+
51+ before_dinner :wash_hand , :turn_off_laptop
52+
53+ def wash_hands ; end
54+
55+ def turn_off_laptop ; end
56+ end
57+ instance = Foo . new
58+ expect ( instance ) . to receive ( :wash_hand ) . once
59+ expect ( instance ) . not_to receive ( :turn_off_laptop )
60+
61+ Hyperloop ::Context . reset!
62+
63+ instance . run_callback ( :before_dinner )
64+ Foo . class_eval do
65+ before_dinner :wash_hand
66+ end
67+ instance . run_callback ( :before_dinner )
68+ end
69+ end # moved elswhere cause its just hard to get anything to work in this environment
70+
4071 it 'defines block callback' do
4172 stub_const 'Foo' , Class . new
4273 Foo . class_eval do
0 commit comments