From 9b712613c597edbf002a3f2a880ba20dae644b1d Mon Sep 17 00:00:00 2001 From: ragaskar Date: Thu, 28 May 2009 20:27:43 -0700 Subject: [PATCH] Added example of nested describes --- README.markdown | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.markdown b/README.markdown index ee3122f..ee1c745 100644 --- a/README.markdown +++ b/README.markdown @@ -251,6 +251,36 @@ Similarly, there is an afterEach declaration. It takes a function that is run a }; }); +### Nested Describes +Jasmine now supports nested describes. An example: + + describe('some suite', function () { + + var suiteWideFoo; + + beforeEach(function () { + suiteWideFoo = 0; + }); + + describe('some nested suite', function() { + var nestedSuiteBar; + beforeEach(function() { + nestedSuiteBar=1; + }); + + it('nested expectation', function () { + expect(suiteWideFoo).toEqual(0); + expect(nestedSuiteBar).toEqual(1); + }; + + }); + + it('top-level describe', function () { + expect(suiteWideFoo).toEqual(0); + expect(nestedSuiteBar).toEqual(undefined); + }; + }); + ### Spies Jasmine integrates 'spies' that permit many spying, mocking, and faking behaviors.