From 072975b523a5ce6c76a3e826876ae358060b60ce Mon Sep 17 00:00:00 2001 From: Yossef Mendelssohn Date: Fri, 24 Oct 2008 17:20:17 -0500 Subject: Having higher-level after blocks also be run for nested contexts. --- lib/bacon.rb | 4 +++- test/spec_bacon.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/bacon.rb b/lib/bacon.rb index 256cd0c..232b2df 100644 --- a/lib/bacon.rb +++ b/lib/bacon.rb @@ -258,7 +258,9 @@ module Kernel private def describe(*args, &block) context = Bacon::Context.new(args.join(' '), &block) - (instance_variable_get('@before') || []).each { |b| context.before &b } + %w[before after].each do |block_type| + (instance_variable_get("@#{block_type}") || []).each { |b| context.send(block_type, &b) } + end context.run context end diff --git a/test/spec_bacon.rb b/test/spec_bacon.rb index b3981ee..a0eeffd 100644 --- a/test/spec_bacon.rb +++ b/test/spec_bacon.rb @@ -299,6 +299,7 @@ describe "before/after" do it "should run in the right order" do @a.should.equal 5 + @a = 2 end end -- cgit 1.4.1