diff options
-rw-r--r-- | lib/bacon.rb | 3 | ||||
-rw-r--r-- | test/spec_bacon.rb | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/bacon.rb b/lib/bacon.rb index ad4df44..47dc31e 100644 --- a/lib/bacon.rb +++ b/lib/bacon.rb @@ -210,6 +210,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) |