Skip to content

Commit 63e2c25

Browse files
author
chrismilleruk
committed
Merge remote-tracking branch 'timblinkbox/angular.js/update1.0.1'
2 parents 49759c9 + f23269b commit 63e2c25

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ end
237237
##
238238
# generates css snippet from a given files and optionally applies simple minification rules
239239
#
240-
def gen_css(cssFile, minify = false)
240+
def gen_css(cssFile, minify = true)
241241
css = ''
242242
File.open(cssFile, 'r') do |f|
243243
css = f.read

css/angular-scenario.css

+6
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ body {
195195
background-color: #efefef;
196196
}
197197

198+
#specs .description {
199+
background-color: #EFEFEF;
200+
padding-left: 20px;
201+
font-style: italic;
202+
}
203+
198204
#application {
199205
border: 1px solid #BABAD1;
200206
}

src/ngScenario/Describe.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
*
77
* @param {string} descName Name of the block
88
* @param {Object} parent describe or undefined if the root.
9+
* @param {string} descDescription Description of the block
910
*/
10-
angular.scenario.Describe = function(descName, parent) {
11+
angular.scenario.Describe = function(descName, parent, descDescription) {
1112
this.only = parent && parent.only;
1213
this.beforeEachFns = [];
1314
this.afterEachFns = [];
1415
this.its = [];
1516
this.children = [];
1617
this.name = descName;
18+
this.description = descDescription;
1719
this.parent = parent;
1820
this.id = angular.scenario.Describe.id++;
1921

@@ -65,9 +67,10 @@ angular.scenario.Describe.prototype.afterEach = function(body) {
6567
*
6668
* @param {string} name Name of the block. Appended to the parent block's name.
6769
* @param {function()} body Body of the block.
70+
* @param {string} description Description of the block. Appended to the parent block's name.
6871
*/
69-
angular.scenario.Describe.prototype.describe = function(name, body) {
70-
var child = new angular.scenario.Describe(name, this);
72+
angular.scenario.Describe.prototype.describe = function(name, body, description) {
73+
var child = new angular.scenario.Describe(name, this, description);
7174
this.children.push(child);
7275
body.call(child);
7376
};

src/ngScenario/Runner.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ angular.scenario.Runner = function($window) {
1212
this.rootDescribe = new angular.scenario.Describe();
1313
this.currentDescribe = this.rootDescribe;
1414
this.api = {
15-
it: this.it,
15+
it: this.it,
1616
iit: this.iit,
1717
xit: angular.noop,
1818
describe: this.describe,
19+
describeStart: this.describeStart,
1920
ddescribe: this.ddescribe,
2021
xdescribe: angular.noop,
2122
beforeEach: this.beforeEach,
@@ -76,6 +77,27 @@ angular.scenario.Runner.prototype.describe = function(name, body) {
7677
});
7778
};
7879

80+
/**
81+
* Defines a describe block of a spec, but allows the body to callback when the describe has been processed.
82+
*
83+
* @see Describe.js
84+
*
85+
* @param {string} name Name of the block
86+
* @param {function()} body Body of the block
87+
* @param {string} description Description of the block
88+
*/
89+
angular.scenario.Runner.prototype.describeStart = function(name, body, description) {
90+
var self = this;
91+
this.currentDescribe.describe(name, function() {
92+
var parentDescribe = self.currentDescribe;
93+
var endDescribeCallback = function() {self.currentDescribe = parentDescribe;};
94+
95+
self.currentDescribe = this;
96+
body.call(this, endDescribeCallback);
97+
},
98+
description);
99+
};
100+
79101
/**
80102
* Same as describe, but makes ddescribe the only blocks to run.
81103
*

src/ngScenario/output/Html.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,20 @@ angular.scenario.output('html', function(context, runner, model) {
133133
currentContext.find('> .test-children').append(
134134
'<div class="test-describe" id="' + id + '">' +
135135
' <h2></h2>' +
136+
' <div class="description" style="display: none;"></div>' +
136137
' <div class="test-children"></div>' +
137138
' <ul class="tests"></ul>' +
138139
'</div>'
139140
);
140-
context.find('#' + id).find('> h2').text('describe: ' + defn.name);
141+
context.find('#' + id).find('> h2').text(defn.name);
142+
143+
// Add the description if it exists
144+
if(!!defn.description)
145+
{
146+
var $description = context.find('#' + id).find('> .description');
147+
$description.text(defn.description);
148+
$description.show();
149+
}
141150
}
142151
currentContext = context.find('#' + id);
143152
});

0 commit comments

Comments
 (0)