Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Added xdescribe
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Remeika committed Jun 28, 2011
1 parent e03a5b3 commit 6549581
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 5 deletions.
16 changes: 16 additions & 0 deletions site/www/src/documents/documentation.html
Expand Up @@ -129,6 +129,22 @@ <h3>describe (aka group)</h3>
</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>
Expand Down
28 changes: 28 additions & 0 deletions 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);
});
});
});
}});
7 changes: 7 additions & 0 deletions spec/shared/keyword_spec.js
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions src/example.js
Expand Up @@ -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;
Expand All @@ -216,4 +214,8 @@ foounit.mixin(foounit.Example.prototype, {
, getTest: function (){
return this._test;
}

, setStatus: function (code){
this._status = code;
}
});
17 changes: 16 additions & 1 deletion 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 = [];
Expand All @@ -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);
}

Expand All @@ -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;
}
});
19 changes: 18 additions & 1 deletion src/keywords.js
Expand Up @@ -41,7 +41,6 @@ foounit.addKeyword('after', function (func){
group.setAfter(func);
});


/**
* Defines a group in the BuildContext
*/
Expand All @@ -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
*/
Expand Down

0 comments on commit 6549581

Please sign in to comment.