summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/bacon.rb3
-rw-r--r--test/spec_bacon.rb16
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/bacon.rb b/lib/bacon.rb
index 6ba913b..371e9ab 100644
--- a/lib/bacon.rb
+++ b/lib/bacon.rb
@@ -211,6 +211,9 @@ module Bacon
 
     def describe(*args, &block)
       context = Bacon::Context.new(args.join(' '), &block)
+      (parent_context = self).methods(false).each {|e|
+        class<<context; self end.send(:define_method, e) {|*args| parent_context.send(e, *args)}
+      }
       @before.each { |b| context.before(&b) }
       @after.each { |b| context.after(&b) }
       context.run
diff --git a/test/spec_bacon.rb b/test/spec_bacon.rb
index b1360be..79cdeb1 100644
--- a/test/spec_bacon.rb
+++ b/test/spec_bacon.rb
@@ -344,6 +344,22 @@ describe "shared/behaves_like" do
   behaves_like "another shared context"
 end
 
+describe "Methods" do
+  def the_meaning_of_life
+    42
+  end
+
+  it "should be accessible in a test" do
+    the_meaning_of_life.should == 42
+  end
+
+  describe "when in a sibling context" do
+    it "should be accessible in a test" do
+      the_meaning_of_life.should == 42
+    end
+  end
+end
+
 describe 'describe arguments' do
 
   def check(ctx,name)