public
Description: RSpec-syntax compatible framework for RubySpecs
Homepage: http://rubyspec.org
Clone URL: git://github.com/rubyspec/mspec.git
Search Repo:
Added RSpec-style shared 'describe' blocks.
brixen (author)
Mon Jul 14 22:19:53 -0700 2008
commit  f848e7380bb3aca680d17561d5fa7558761aee23
tree    252b13d2c999c9176a032817efb1d766b5768b64
parent  1ac5420adb097efaf37050071b955916b818587c
...
13
14
15
16
 
 
 
 
 
 
 
 
 
 
 
17
18
19
20
21
...
25
26
27
 
28
29
30
31
32
 
 
 
 
 
 
33
34
35
 
36
37
 
38
39
40
...
76
77
78
79
80
 
81
82
83
84
85
86
87
88
89
90
 
 
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
93
 
 
 
 
94
95
96
97
98
 
 
99
100
101
102
 
103
104
 
105
106
107
 
 
108
109
110
...
13
14
15
 
16
17
18
19
20
21
22
23
24
25
26
27
 
28
29
30
...
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
54
55
56
57
...
93
94
95
 
 
96
97
98
99
 
 
 
 
 
 
 
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
 
139
140
 
141
142
143
144
145
146
147
148
149
0
@@ -13,9 +13,18 @@ require 'mspec/runner/example'
0
 # is evaluated, just as +it+ refers to the example itself.
0
 #++
0
 class ContextState
0
- attr_reader :state, :parent, :parents, :children, :examples, :description
0
+ attr_reader :state, :parent, :parents, :children, :examples, :to_s
0
+
0
+ def initialize(mod, options=nil)
0
+ @to_s = mod.to_s
0
+ if options.is_a? Hash
0
+ @options = options
0
+ else
0
+ @to_s += "#{".:#".include?(options[0,1]) ? "" : " "}#{options}" if options
0
+ @options = { }
0
+ end
0
+ @options[:shared] ||= false
0
 
0
- def initialize
0
     @parsed = false
0
     @before = { :all => [], :each => [] }
0
     @after = { :all => [], :each => [] }
0
@@ -25,16 +34,24 @@ class ContextState
0
     @parent = nil
0
     @parents = [self]
0
     @children = []
0
+
0
     @mock_verify = lambda { Mock.verify_count }
0
     @mock_cleanup = lambda { Mock.cleanup }
0
     @expectation_missing = lambda { raise ExpectationNotFoundError }
0
   end
0
 
0
+ # Returns true if this is a shared +ContextState+. Essentially, when
0
+ # created with: describe "Something", :shared => true { ... }
0
+ def shared?
0
+ return @options[:shared]
0
+ end
0
+
0
   # Set the parent (enclosing) +ContextState+ for this state. Creates
0
   # the +parents+ list.
0
   def parent=(parent)
0
+ @description = nil
0
     @parent = parent
0
- parent.child self if parent
0
+ parent.child self if parent and not shared?
0
 
0
     state = parent
0
     while state
0
@@ -76,35 +93,57 @@ class ContextState
0
   # Creates an ExampleState instance for the block and stores it
0
   # in a list of examples to evaluate unless the example is filtered.
0
   def it(desc, &block)
0
- example = ExampleState.new @description, desc, block
0
- @examples << example unless example.filtered?
0
+ @examples << ExampleState.new(self, desc, block)
0
   end
0
 
0
   # Evaluates the block and resets the toplevel +ContextState+ to #parent.
0
- def describe(mod, desc=nil, &block)
0
- description = parents.inject([]) { |l, s| l << s.description }.compact
0
- sep = /^(::|[.#])/ =~ desc ? "" : " "
0
- description << (desc ? "#{mod}#{sep}#{desc}" : mod.to_s)
0
- @description = description.join " "
0
-
0
- @parsed = protect @description, block, false
0
+ def describe(&block)
0
+ @parsed = protect @to_s, block, false
0
     MSpec.register_current parent
0
+ MSpec.register_shared self if shared?
0
+ end
0
+
0
+ # Returns a description string generated from self and all parents
0
+ def description
0
+ @description ||= parents.inject([]) { |l,s| l << s.to_s }.join(" ")
0
+ end
0
+
0
+ # Injects the before/after blocks and examples from the shared
0
+ # describe block into this +ContextState+ instance.
0
+ def it_should_behave_like(desc)
0
+ unless state = MSpec.retrieve_shared(desc)
0
+ raise Exception, "Unable to find shared 'describe' for #{desc}"
0
+ end
0
+
0
+ state.examples.each { |ex| ex.context = self; @examples << ex }
0
+ state.before(:all).each { |b| before :all, &b }
0
+ state.before(:each).each { |b| before :each, &b }
0
+ state.after(:each).each { |b| after :each, &b }
0
+ state.after(:all).each { |b| after :all, &b }
0
   end
0
 
0
+ # Evaluates each block in +blocks+ using the +MSpec.protect+ method
0
+ # so that exceptions are handled and tallied. Returns true and does
0
+ # NOT evaluate any blocks if +check+ is true and +MSpec.pretend_mode?+
0
+ # is true.
0
   def protect(what, blocks, check=true)
0
     return true if check and MSpec.pretend_mode?
0
     Array(blocks).all? { |block| MSpec.protect what, &block }
0
   end
0
 
0
+ # Evaluates the examples in a +ContextState+. Invokes the MSpec events
0
+ # for :enter, :before, :after, :leave.
0
   def process
0
     MSpec.register_current self
0
 
0
- if @parsed and @examples.any? { |example| example.unfiltered? }
0
+ if @parsed
0
       MSpec.shuffle @examples if MSpec.randomize?
0
- MSpec.actions :enter, @description
0
+ MSpec.actions :enter, description
0
 
0
       if protect "before :all", pre(:all)
0
         @examples.each do |state|
0
+ next if state.filtered?
0
+
0
           @state = state
0
           example = state.example
0
           MSpec.actions :before, state
...
3
4
5
6
 
7
8
9
10
11
12
 
 
 
 
13
14
15
16
 
 
 
 
 
 
 
17
18
19
20
21
22
23
24
25
26
 
 
27
28
29
30
 
 
 
 
 
31
32
...
3
4
5
 
6
7
 
 
 
 
 
8
9
10
11
12
13
 
 
14
15
16
17
18
19
20
21
22
 
 
 
 
 
 
 
 
23
24
25
26
27
 
28
29
30
31
32
33
34
0
@@ -3,30 +3,32 @@ require 'mspec/runner/mspec'
0
 # Holds some of the state of the example (i.e. +it+ block) that is
0
 # being evaluated. See also +ContextState+.
0
 class ExampleState
0
- attr_reader :describe, :it, :example
0
+ attr_reader :context, :it, :example
0
 
0
- def initialize(describe, it, example=nil)
0
- @describe = describe
0
- @it = it
0
- @example = example
0
- @unfiltered = nil
0
+ def initialize(context, it, example=nil)
0
+ @context = context
0
+ @it = it
0
+ @example = example
0
   end
0
 
0
- def description
0
- @description ||= "#{@describe} #{@it}"
0
+ def context=(context)
0
+ @description = nil
0
+ @context = context
0
+ end
0
+
0
+ def describe
0
+ @context.description
0
   end
0
 
0
- def unfiltered?
0
- unless @unfiltered
0
- incl = MSpec.retrieve(:include) || []
0
- excl = MSpec.retrieve(:exclude) || []
0
- @unfiltered = incl.empty? || incl.any? { |f| f === description }
0
- @unfiltered &&= excl.empty? || !excl.any? { |f| f === description }
0
- end
0
- @unfiltered
0
+ def description
0
+ @description ||= "#{describe} #{@it}"
0
   end
0
 
0
   def filtered?
0
- not unfiltered?
0
+ incl = MSpec.retrieve(:include) || []
0
+ excl = MSpec.retrieve(:exclude) || []
0
+ included = incl.empty? || incl.any? { |f| f === description }
0
+ included &&= excl.empty? || !excl.any? { |f| f === description }
0
+ not included
0
   end
0
 end
...
19
20
21
 
22
23
24
25
26
27
28
 
 
29
30
31
32
 
33
34
 
35
36
37
...
86
87
88
 
 
 
 
 
 
 
 
 
 
 
89
90
91
92
 
93
94
95
96
 
97
98
99
...
19
20
21
22
23
24
25
26
27
 
 
28
29
30
31
32
 
33
34
 
35
36
37
38
...
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
0
@@ -19,19 +19,20 @@ module MSpec
0
   @load = nil
0
   @unload = nil
0
   @current = nil
0
+ @shared = {}
0
   @exception = nil
0
   @randomize = nil
0
   @expectation = nil
0
   @expectations = false
0
 
0
- def self.describe(mod, msg=nil, &block)
0
- state = ContextState.new
0
+ def self.describe(mod, options=nil, &block)
0
+ state = ContextState.new mod, options
0
     state.parent = current
0
 
0
     MSpec.register_current state
0
- state.describe(mod, msg, &block)
0
+ state.describe(&block)
0
 
0
- state.process unless MSpec.current
0
+ state.process unless state.shared? or current
0
   end
0
 
0
   def self.process
0
@@ -86,14 +87,27 @@ module MSpec
0
     retrieve :current
0
   end
0
 
0
+ # Stores the shared ContextState keyed by description.
0
+ def self.register_shared(state)
0
+ @shared[state.to_s] = state
0
+ end
0
+
0
+ # Returns the shared ContextState matching description.
0
+ def self.retrieve_shared(desc)
0
+ @shared[desc.to_s]
0
+ end
0
+
0
+ # Stores the exit code used by the runner scripts.
0
   def self.register_exit(code)
0
     store :exit, code
0
   end
0
 
0
+ # Retrieves the stored exit code.
0
   def self.exit_code
0
     retrieve(:exit).to_i
0
   end
0
 
0
+ # Stores the list of files to be evaluated.
0
   def self.register_files(files)
0
     store :files, files
0
   end
...
7
8
9
10
 
11
12
13
...
15
16
17
 
 
 
 
18
19
20
...
7
8
9
 
10
11
12
13
...
15
16
17
18
19
20
21
22
23
24
0
@@ -7,7 +7,7 @@ class Object
0
     MSpec.current.after at, &block
0
   end
0
 
0
- def describe(mod, msg=nil, &block)
0
+ def describe(mod, msg=nil, options=nil, &block)
0
     MSpec.describe mod, msg, &block
0
   end
0
 
0
@@ -15,6 +15,10 @@ class Object
0
     MSpec.current.it msg, &block
0
   end
0
 
0
+ def it_should_behave_like(desc)
0
+ MSpec.current.it_should_behave_like desc
0
+ end
0
+
0
   alias_method :context, :describe
0
   alias_method :specify, :it
0
 end
...
1
2
3
4
5
6
 
 
 
 
 
7
8
9
10
 
11
12
...
1
2
3
 
 
 
4
5
6
7
8
9
 
 
 
10
11
12
0
@@ -1,12 +1,12 @@
0
 require 'mspec/runner/mspec'
0
 
0
 class Object
0
- def shared(msg, &block)
0
- MSpec.store msg.to_sym, block
0
- end
0
+ def it_behaves_like(desc, meth, obj=nil)
0
+ send :before, :all do
0
+ @method = meth
0
+ @object = obj if obj
0
+ end
0
 
0
- def it_behaves_like(behavior, *args)
0
- p = MSpec.retrieve behavior.to_sym
0
- p[*args]
0
+ send :it_should_behave_like, desc.to_s
0
   end
0
 end
...
1
2
3
 
4
5
6
...
18
19
20
21
 
22
23
24
...
1
2
3
4
5
6
7
...
19
20
21
 
22
23
24
25
0
@@ -1,6 +1,7 @@
0
 require File.dirname(__FILE__) + '/../../spec_helper'
0
 require 'mspec/runner/actions/debug'
0
 require 'mspec/runner/mspec'
0
+require 'mspec/runner/context'
0
 require 'mspec/runner/example'
0
 
0
 describe DebugAction do
0
@@ -18,7 +19,7 @@ end
0
 describe DebugAction, "#before" do
0
   before :each do
0
     MSpec.stub!(:read_tags).and_return([])
0
- @state = ExampleState.new "Catch#me", "if you can"
0
+ @state = ExampleState.new ContextState.new("Catch#me"), "if you can"
0
   end
0
 
0
   it "does not invoke the debugger if the description does not match" do
...
18
19
20
21
 
22
23
24
...
18
19
20
 
21
22
23
24
0
@@ -18,7 +18,7 @@ end
0
 describe GdbAction, "#before" do
0
   before :each do
0
     MSpec.stub!(:read_tags).and_return([])
0
- @state = ExampleState.new "Catch#me", "if you can"
0
+ @state = ExampleState.new ContextState.new("Catch#me"), "if you can"
0
   end
0
 
0
   it "does not invoke the debugger if the description does not match" do
...
94
95
96
97
 
98
99
100
...
111
112
113
114
 
 
115
116
117
...
159
160
161
162
 
 
163
164
165
...
207
208
209
210
 
 
211
212
213
...
94
95
96
 
97
98
99
100
...
111
112
113
 
114
115
116
117
118
...
160
161
162
 
163
164
165
166
167
...
209
210
211
 
212
213
214
215
216
0
@@ -94,7 +94,7 @@ describe TagAction, "#before" do
0
     action.exception?.should be_false
0
     action.exception ExceptionState.new(nil, nil, Exception.new("Fail!"))
0
     action.exception?.should be_true
0
- action.before(ExampleState.new("describe", "it"))
0
+ action.before(ExampleState.new(ContextState.new("describe"), "it"))
0
     action.exception?.should be_false
0
   end
0
 end
0
@@ -111,7 +111,8 @@ end
0
 describe TagAction, "#after when action is :add" do
0
   before :each do
0
     MSpec.stub!(:read_tags).and_return([])
0
- @state = ExampleState.new "Catch#me", "if you can"
0
+ context = ContextState.new "Catch#me"
0
+ @state = ExampleState.new context, "if you can"
0
     @tag = SpecTag.new "tag(comment):Catch#me if you can"
0
     SpecTag.stub!(:new).and_return(@tag)
0
     @exception = ExceptionState.new nil, nil, Exception.new("failed")
0
@@ -159,7 +160,8 @@ end
0
 describe TagAction, "#after when action is :del" do
0
   before :each do
0
     MSpec.stub!(:read_tags).and_return([])
0
- @state = ExampleState.new "Catch#me", "if you can"
0
+ context = ContextState.new "Catch#me"
0
+ @state = ExampleState.new context, "if you can"
0
     @tag = SpecTag.new "tag(comment):Catch#me if you can"
0
     SpecTag.stub!(:new).and_return(@tag)
0
     @exception = ExceptionState.new nil, nil, Exception.new("failed")
0
@@ -207,7 +209,8 @@ end
0
 describe TagAction, "#finish" do
0
   before :each do
0
     $stdout = @out = IOStub.new
0
- @state = ExampleState.new "Catch#me", "if you can"
0
+ context = ContextState.new "Catch#me"
0
+ @state = ExampleState.new context, "if you can"
0
     MSpec.stub!(:write_tag).and_return(true)
0
     MSpec.stub!(:delete_tag).and_return(true)
0
   end
...
7
8
9
10
 
11
12
13
14
15
16
 
17
18
19
20
21
22
23
 
 
 
24
25
26
27
 
28
29
30
 
31
32
33
34
35
 
 
 
 
36
37
38
39
40
41
 
 
 
42
43
 
 
 
 
 
 
44
45
46
 
47
48
49
50
51
 
52
53
54
55
56
 
57
58
59
60
61
 
62
63
64
65
66
 
67
68
69
70
71
 
72
73
74
75
 
76
77
78
79
 
 
80
81
82
83
84
 
 
 
85
86
87
88
89
90
91
 
92
93
94
95
96
97
98
 
 
99
100
101
102
103
104
105
 
106
107
108
...
114
115
116
117
 
118
119
120
...
131
132
133
134
 
135
136
137
...
152
153
154
155
 
156
157
158
159
 
160
161
162
...
179
180
181
182
 
183
184
185
186
 
187
188
189
...
210
211
212
213
 
214
215
216
217
218
219
 
220
221
222
223
224
 
225
226
227
228
229
 
230
231
232
233
 
234
235
236
237
238
239
 
240
241
242
243
244
 
 
 
 
 
 
245
246
247
...
255
256
257
258
 
259
260
261
...
273
274
275
276
277
 
 
278
279
280
...
289
290
291
292
293
 
 
294
295
296
...
304
305
306
307
308
309
 
 
 
310
311
312
...
322
323
324
325
 
326
327
328
...
331
332
333
334
 
335
336
337
...
345
346
347
348
349
 
 
350
351
352
...
376
377
378
 
 
 
 
 
 
 
 
379
380
381
...
408
409
410
411
 
412
413
414
415
416
417
418
 
419
420
421
...
454
455
456
457
 
458
459
460
...
462
463
464
465
 
466
467
468
...
473
474
475
476
477
 
 
478
479
480
...
513
514
515
516
517
 
 
518
519
520
...
549
550
551
552
553
 
 
554
555
556
...
585
586
587
588
589
590
591
592
593
594
595
596
 
 
597
598
599
...
604
605
606
607
 
608
609
610
...
624
625
626
627
628
 
 
629
630
631
...
684
685
686
687
688
 
 
689
690
691
...
733
734
735
736
737
 
 
738
739
740
...
781
782
783
784
785
 
 
786
787
788
...
791
792
793
794
 
795
796
797
...
856
857
858
859
860
 
 
861
862
863
...
882
883
884
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
7
8
9
 
10
11
12
13
14
15
 
16
17
18
19
 
 
 
 
20
21
22
23
24
25
 
26
27
28
 
29
30
31
 
 
 
32
33
34
35
36
37
38
 
 
 
39
40
41
42
43
44
45
46
47
48
49
50
 
 
51
52
53
54
 
 
55
56
57
58
 
 
59
60
61
62
 
 
63
64
65
66
 
 
67
68
69
70
 
 
71
72
73
74
 
75
76
 
 
 
77
78
79
80
81
 
 
82
83
84
85
86
87
88
89
90
 
91
92
93
94
95
96
 
 
97
98
99
100
101
102
103
104
 
105
106
107
108
...
114
115
116
 
117
118
119
120
...
131
132
133
 
134
135
136
137
...
152
153
154
 
155
156
157
158
 
159
160
161
162
...
179
180
181
 
182
183
184
185
 
186
187
188
189
...
210
211
212
 
213
214
215
216
217
218
 
219
220
221
222
223
 
224
225
226
227
228
 
229
230
231
232
 
233
234
235
236
237
238
 
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
261
262
263
 
264
265
266
267
...
279
280
281
 
 
282
283
284
285
286
...
295
296
297
 
 
298
299
300
301
302
...
310
311
312
 
 
 
313
314
315
316
317
318
...
328
329
330
 
331
332
333
334
...
337
338
339
 
340
341
342
343
...
351
352
353
 
 
354
355
356
357
358
...
382
383
384
385
386
387
388
389
390
391
392
393
394
395
...
422
423
424
 
425
426
427
428
429
430
431
 
432
433
434
435
...
468
469
470
 
471
472
473
474
...
476
477
478
 
479
480
481
482
...
487
488
489
 
 
490
491
492
493
494
...
527
528
529
 
 
530
531
532
533
534
...
563
564
565
 
 
566
567
568
569
570
...
599
600
601
 
 
 
602
603
604
605
 
 
606
607
608
609
610
...
615
616
617
 
618
619
620
621
...
635
636
637
 
 
638
639
640
641
642
...
695
696
697
 
 
698
699
700
701
702
...
744
745
746
 
 
747
748
749
750
751
...
792
793
794
 
 
795
796
797
798
799
...
802
803
804
 
805
806
807
808
...
867
868
869
 
 
870
871
872
873
874
...
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
0
@@ -7,102 +7,102 @@ require 'mspec/runner/context'
0
 
0
 describe ContextState, "#describe" do
0
   before :each do
0
- @state = ContextState.new
0
+ @state = ContextState.new "C#m"
0
     @proc = lambda { ScratchPad.record :a }
0
     ScratchPad.clear
0
   end
0
 
0
   it "evaluates the passed block" do
0
- @state.describe(Object, &@proc)
0
+ @state.describe(&@proc)
0
     ScratchPad.recorded.should == :a
0
   end
0
 
0
- it "sets the description string" do
0
- @state.description.should be_nil
0
- @state.describe("Object#to_s") { }
0
- @state.description.should == "Object#to_s"
0
+ it "evaluates the passed block via #protect" do
0
+ @state.should_receive(:protect).with("C#m", @proc, false)
0
+ @state.describe(&@proc)
0
   end
0
 
0
   it "registers #parent as the current MSpec ContextState" do
0
- parent = ContextState.new
0
+ parent = ContextState.new ""
0
     @state.parent = parent
0
     MSpec.should_receive(:register_current).with(parent)
0
- @state.describe("C#m") { }
0
+ @state.describe { }
0
   end
0
 
0
- it "registers nil as the current MSpec ContextState if it has no parent" do
0
- MSpec.should_receive(:register_current).with(nil)
0
- @state.describe("C#m") { }
0
+ it "registers self with MSpec when #shared? is true" do
0
+ state = ContextState.new "something shared", :shared => true
0
+ MSpec.should_receive(:register_shared).with(state)
0
+ state.describe { }
0
   end
0
 end
0
 
0
-describe ContextState, "#description when there are no parents" do
0
- before :each do
0
- @state = ContextState.new
0
+describe ContextState, "#shared?" do
0
+ it "returns false when the ContextState is not shared" do
0
+ ContextState.new("").shared?.should be_false
0
   end
0
 
0
+ it "returns true when the ContextState is shared" do
0
+ ContextState.new("", {:shared => true}).shared?.should be_true
0
+ end
0
+end
0
+
0
+describe ContextState, "#to_s" do
0
   it "returns a description string for self when passed a Module" do
0
- @state.describe(Object) { }
0
- @state.description.should == "Object"
0
+ ContextState.new(Object).to_s.should == "Object"
0
   end
0
 
0
   it "returns a description string for self when passed a String" do
0
- @state.describe("SomeClass") { }
0
- @state.description.should == "SomeClass"
0
+ ContextState.new("SomeClass").to_s.should == "SomeClass"
0
   end
0
 
0
   it "returns a description string for self when passed a Module, String" do
0
- @state.describe(Object, "when empty") { }
0
- @state.description.should == "Object when empty"
0
+ ContextState.new(Object, "when empty").to_s.should == "Object when empty"
0
   end
0
 
0
   it "returns a description string for self when passed a Module and String beginning with '#'" do
0
- @state.describe(Object, "#to_s") { }
0
- @state.description.should == "Object#to_s"
0
+ ContextState.new(Object, "#to_s").to_s.should == "Object#to_s"
0
   end
0
 
0
   it "returns a description string for self when passed a Module and String beginning with '.'" do
0
- @state.describe(Object, ".to_s") { }
0
- @state.description.should == "Object.to_s"
0
+ ContextState.new(Object, ".to_s").to_s.should == "Object.to_s"
0
   end
0
 
0
   it "returns a description string for self when passed a Module and String beginning with '::'" do
0
- @state.describe(Object, "::to_s") { }
0
- @state.description.should == "Object::to_s"
0
+ ContextState.new(Object, "::to_s").to_s.should == "Object::to_s"
0
   end
0
 end
0
 
0
-describe ContextState, "#description when there are parents" do
0
+describe ContextState, "#description" do
0
   before :each do
0
- @state = ContextState.new
0
- @parent = ContextState.new
0
- @state.parent = @parent
0
+ @state = ContextState.new "when empty"
0
+ @parent = ContextState.new "Toplevel"
0
   end
0
 
0
   it "returns a composite description string from self and all parents" do
0
- @parent.describe("Toplevel") { }
0
- @state.describe("when empty") { }
0
+ @parent.description.should == "Toplevel"
0
+ @state.description.should == "when empty"
0
+ @state.parent = @parent
0
     @state.description.should == "Toplevel when empty"
0
   end
0
 end
0
 
0
 describe ContextState, "#it" do
0
   before :each do
0
- @state = ContextState.new
0
+ @state = ContextState.new ""
0
     @proc = lambda { }
0
   end
0
 
0
   it "creates an ExampleState instance for the block" do
0
     ex = ExampleState.new("", "", &@proc)
0
- ExampleState.should_receive(:new).with("describe", "it", @proc).and_return(ex)
0
- @state.describe("describe", &@proc)
0
+ ExampleState.should_receive(:new).with(@state, "it", @proc).and_return(ex)
0
+ @state.describe(&@proc)
0
     @state.it("it", &@proc)
0
   end
0
 end
0
 
0
 describe ContextState, "#examples" do
0
   before :each do
0
- @state = ContextState.new
0
+ @state = ContextState.new ""
0
   end
0
 
0
   it "returns a list of all examples in this ContextState" do
0
@@ -114,7 +114,7 @@ end
0
 
0
 describe ContextState, "#before" do
0
   before :each do
0
- @state = ContextState.new