lib/context/lifecycle.rb in jeremymcanally-context-0.5 vs lib/context/lifecycle.rb in jeremymcanally-context-0.5.2
- old
+ new
@@ -10,19 +10,23 @@
#
def before(period = :each, &block)
send("before_#{period}_callbacks") << block
end
+ alias :setup :before
+
# Add logic to run after the tests (i.e., a +teardown+ method)
#
# after do
# User.delete_all
# end
#
def after(period = :each, &block)
send("after_#{period}_callbacks") << block
end
+
+ alias :teardown :after
def gather_callbacks(callback_type, period) # :nodoc:
callbacks = superclass.respond_to?(:gather_callbacks) ? superclass.gather_callbacks(callback_type, period) : []
callbacks.push(*send("#{callback_type}_#{period}_callbacks"))
end
@@ -39,16 +43,18 @@
child.before_each_callbacks = []
child.after_each_callbacks = []
child.after_all_callbacks = []
child.class_eval do
- def setup
+ def setup(&block)
super
+
run_each_callbacks :before
end
def teardown
super
+
run_each_callbacks :after
end
end
end
\ No newline at end of file