visionmedia-jspec 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +5 -0
- data/README.rdoc +1 -0
- data/bin/jspec +1 -1
- data/jspec.gemspec +1 -1
- data/lib/jspec.js +3 -2
- data/spec/spec.grammar.js +32 -2
- metadata +1 -1
data/History.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -15,6 +15,7 @@ and much more.
|
|
15
15
|
* Ruby JavaScript testing server
|
16
16
|
* Nested describes
|
17
17
|
* Does not pollute core object prototypes
|
18
|
+
* Cascading before/after/before_each/after_each hooks
|
18
19
|
* Extremely simple and intuitive matcher declaration
|
19
20
|
* Over 45 core matchers
|
20
21
|
* Allows parens to be optional when using matchers to increase readability
|
data/bin/jspec
CHANGED
data/jspec.gemspec
CHANGED
data/lib/jspec.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
JSpec = {
|
7
7
|
|
8
|
-
version : '1.1.
|
8
|
+
version : '1.1.5',
|
9
9
|
file : '',
|
10
10
|
suites : [],
|
11
11
|
matchers : {},
|
@@ -249,6 +249,7 @@
|
|
249
249
|
// Invoke a hook in context to this suite
|
250
250
|
|
251
251
|
hook : function(hook) {
|
252
|
+
if (this.suite) this.suite.hook(hook)
|
252
253
|
each(this.hooks[hook], function(body) {
|
253
254
|
JSpec.evalBody(body, "Error in hook '" + hook + "', suite '" + this.description + "': ")
|
254
255
|
})
|
@@ -787,12 +788,12 @@
|
|
787
788
|
this.runSpec(spec)
|
788
789
|
suite.hook('after_each')
|
789
790
|
})
|
790
|
-
suite.hook('after')
|
791
791
|
if (suite.hasSuites()) {
|
792
792
|
each(suite.suites, function(suite) {
|
793
793
|
this.runSuite(suite)
|
794
794
|
})
|
795
795
|
}
|
796
|
+
suite.hook('after')
|
796
797
|
return this
|
797
798
|
},
|
798
799
|
|
data/spec/spec.grammar.js
CHANGED
@@ -76,55 +76,85 @@ describe 'Grammar'
|
|
76
76
|
end
|
77
77
|
|
78
78
|
describe 'before / after blocks'
|
79
|
-
var n, o
|
79
|
+
var n, o, hits = []
|
80
80
|
|
81
81
|
before
|
82
82
|
n = 1
|
83
|
+
hits.push('before')
|
83
84
|
end
|
84
85
|
|
85
86
|
after
|
86
87
|
n = 0
|
88
|
+
hits.push('after')
|
87
89
|
end
|
88
90
|
|
89
91
|
it 'should work'
|
90
92
|
n.should.eql 1
|
93
|
+
hits.should.eql ['before']
|
91
94
|
n++
|
92
95
|
end
|
93
96
|
|
94
97
|
it 'should persist'
|
95
98
|
n.should.eql 2
|
99
|
+
hits.should.eql ['before']
|
96
100
|
end
|
97
101
|
|
98
102
|
describe 'with nested describe'
|
99
103
|
it 'should be accessable'
|
100
|
-
n.should.eql
|
104
|
+
n.should.eql 1
|
105
|
+
hits.should.eql ['before', 'before']
|
101
106
|
end
|
102
107
|
end
|
103
108
|
end
|
104
109
|
|
105
110
|
describe 'before_each / after_each blocks'
|
111
|
+
hits = []
|
112
|
+
|
106
113
|
before_each
|
107
114
|
n = 1
|
115
|
+
hits.push('before_each')
|
108
116
|
end
|
109
117
|
|
110
118
|
after_each
|
111
119
|
o = 2
|
120
|
+
hits.push('after_each')
|
112
121
|
end
|
113
122
|
|
114
123
|
it 'should work'
|
115
124
|
n.should.eql 1
|
125
|
+
hits.should.eql ['before_each']
|
116
126
|
n = 2
|
117
127
|
end
|
118
128
|
|
119
129
|
it 'should not persist'
|
120
130
|
n.should.eql 1
|
121
131
|
o.should.eql 2
|
132
|
+
hits.should.eql ['before_each', 'after_each', 'before_each']
|
122
133
|
end
|
123
134
|
|
124
135
|
describe 'with nested describe'
|
125
136
|
it 'should be accessable'
|
126
137
|
n.should.eql 1
|
127
138
|
o.should.eql 2
|
139
|
+
hits.should.eql ['before_each', 'after_each', 'before_each', 'after_each', 'before_each']
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should continue hits'
|
143
|
+
hits.should.eql ['before_each', 'after_each', 'before_each', 'after_each', 'before_each', 'after_each', 'before_each']
|
144
|
+
end
|
145
|
+
|
146
|
+
describe 'with more hooks'
|
147
|
+
before_each
|
148
|
+
hits.push('before_each')
|
149
|
+
end
|
150
|
+
|
151
|
+
after_each
|
152
|
+
hits.push('after_each')
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should continue hits, while cascading properly'
|
156
|
+
hits.should.eql ['before_each', 'after_each', 'before_each', 'after_each', 'before_each', 'after_each', 'before_each', 'after_each', 'before_each', 'before_each']
|
157
|
+
end
|
128
158
|
end
|
129
159
|
end
|
130
160
|
end
|