summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2007-12-05 01:41:56 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2007-12-05 01:41:56 +0100
commit4bd8f7f165ba8113870a6be9ee4f11474aea892d (patch)
tree812fb42b19803d27080ab371fed8b879d1efa91f /test
parent20eb0d3b1d0cae1bb26b9d7f91aad90c145438ff (diff)
downloadbacon-4bd8f7f165ba8113870a6be9ee4f11474aea892d.tar.gz
bacon-4bd8f7f165ba8113870a6be9ee4f11474aea892d.tar.xz
bacon-4bd8f7f165ba8113870a6be9ee4f11474aea892d.zip
Add shared contexts
darcs-hash:20071205004156-4fc50-50fb9e4bd448a79706dff072ecf7efe06df41d3e.gz
Diffstat (limited to 'test')
-rw-r--r--test/spec_bacon.rb30
1 files changed, 30 insertions, 0 deletions
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