From 4bd8f7f165ba8113870a6be9ee4f11474aea892d Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Wed, 5 Dec 2007 01:41:56 +0100 Subject: Add shared contexts darcs-hash:20071205004156-4fc50-50fb9e4bd448a79706dff072ecf7efe06df41d3e.gz --- test/spec_bacon.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test') diff --git a/test/spec_bacon.rb b/test/spec_bacon.rb index f599a7b..cfbb7bb 100644 --- a/test/spec_bacon.rb +++ b/test/spec_bacon.rb @@ -258,3 +258,33 @@ describe "before/after" do @b.should.equal 2 end end + +shared "a shared context" do + it "gets called where it is included" do + true.should.be.true + end +end + +shared "another shared context" do + it "can access data" do + @magic.should.be.equal 42 + end +end + +describe "shared/behaves_like" do + behaves_like "a shared context" + + ctx = self + it "raises NameError when the context is not found" do + lambda { + ctx.behaves_like "whoops" + }.should.raise NameError + end + + behaves_like "a shared context" + + before { + @magic = 42 + } + behaves_like "another shared context" +end -- cgit 1.4.1