Browse files

Added xdescribe

  • Loading branch information...
1 parent e03a5b3 commit 654958150a9278c3749796748421698060126b58 @foobarfighter committed Jun 27, 2011
View
16 site/www/src/documents/documentation.html
@@ -129,6 +129,22 @@
</p>
+<a name=xdescribe"></a>
+<h3>xdescribe (aka group)</h3>
+
+<p>
+ Creates a pending group. All groups and examples nested within a pending group will be marked as pending. This can be used to mark an entire set of tests as pending.
+</p>
+
+<pre class="code">
+xdescribe('example group', function (){
+ it('runs some test', function (){ // This example will be marked as pending and will not run
+ ...
+ });
+});
+</pre>
+
+
<a name="expect"></a>
<a name="assertion"></a>
<h3>expect (aka assertion)</h3>
View
28 spec/shared/example_group_spec.js
@@ -0,0 +1,28 @@
+var footest = foounit.require(':src/foounit');
+
+foounit.add(function (kw){ with(kw){
+ describe('foounit.ExampleGroup', function (){
+ describe('when the pending flag is true', function (){
+ it('makes all examples as pending', function (){
+ var group = new footest.ExampleGroup('parent', function (){}, true);
+
+ expect(group.isPending()).to(beTrue);
+
+ group.setBefore(function (){ runCount++; });
+ group.setAfter(function (){ runCount++; });
+
+ var example = new footest.Example('test1', function (){});
+ group.addExample(example);
+ expect(example.isPending()).to(beTrue);
+
+ var subgroup = new footest.ExampleGroup('subgroup', function (){});
+ group.addGroup(subgroup);
+ expect(subgroup.isPending()).to(beTrue);
+
+ var subexample = new footest.Example('test2', function (){});
+ subgroup.addExample(subexample);
+ expect(subexample.isPending()).to(beTrue);
+ });
+ });
+ });
+}});
View
7 spec/shared/keyword_spec.js
@@ -31,6 +31,13 @@ foounit.add(function (kw){ with(kw){
});
});
+ describe('xdescribe', function (){
+ it('creats a pending group', function (){
+ foo = footest.keywords.xdescribe('pending', function (){});
+ expect(foo.isPending()).to(beTrue);
+ });
+ });
+
describe('matchers', function (){
it('mixes them into the keywords', function (){
var called = false;
View
8 src/example.js
@@ -201,9 +201,7 @@ foounit.mixin(foounit.Example.prototype, {
this._descriptions = descriptions;
}
- , getBefores: function (){
- return this._befores;
- }
+ , getBefores: function (){ return this._befores; }
, setAfters: function (afters){
this._afters = afters;
@@ -216,4 +214,8 @@ foounit.mixin(foounit.Example.prototype, {
, getTest: function (){
return this._test;
}
+
+ , setStatus: function (code){
+ this._status = code;
+ }
});
View
17 src/example_group.js
@@ -1,6 +1,7 @@
-foounit.ExampleGroup = function (description, builder){
+foounit.ExampleGroup = function (description, builder, pending){
this._description = description;
this._builder = builder;
+ this._pending = pending;
this._before = null;
this._after = null;
this._examples = [];
@@ -17,10 +18,16 @@ foounit.mixin(foounit.ExampleGroup.prototype, {
}
, addExample: function (example){
+ if (this.isPending()){
+ example.setStatus(foounit.Example.prototype.PENDING);
+ }
this._examples.push(example);
}
, addGroup: function (group){
+ if (this.isPending()){
+ group.setPending(true);
+ }
this._groups.push(group);
}
@@ -47,4 +54,12 @@ foounit.mixin(foounit.ExampleGroup.prototype, {
, getDescription: function (){
return this._description;
}
+
+ , isPending: function (){
+ return this._pending;
+ }
+
+ , setPending: function (bool){
+ this._pending = bool;
+ }
});
View
19 src/keywords.js
@@ -41,7 +41,6 @@ foounit.addKeyword('after', function (func){
group.setAfter(func);
});
-
/**
* Defines a group in the BuildContext
*/
@@ -57,6 +56,24 @@ foounit.addKeyword('describe', function (description, builder){
context.setCurrentGroup(parentGroup);
});
+/*
+ * Defines a pending group in the BuildContext.
+ * All examples and nested groups within this group will
+ * be marked as pending.
+ */
+foounit.addKeyword('xdescribe', function (description, builder){
+ var context = foounit.getBuildContext()
+ , parentGroup = context.getCurrentGroup()
+ , group = new foounit.ExampleGroup(description, builder, true);
+
+ parentGroup.addGroup(group);
+
+ context.setCurrentGroup(group);
+ group.build();
+ context.setCurrentGroup(parentGroup);
+ return group;
+});
+
/**
* Creates a foounit.Expectation
*/

0 comments on commit 6549581

Please sign in to comment.