rspec-core 2.0.0.a5 → 2.0.0.a6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. data/example_specs/failing/diffing_spec.rb +3 -1
  2. data/example_specs/spec_helper.rb +1 -1
  3. data/features/configuration/spec_opts.feature +7 -7
  4. data/features/example_groups/describe_aliases.feature +1 -1
  5. data/features/example_groups/nested_groups.feature +3 -6
  6. data/features/{before_and_after_blocks/around.feature → hooks/around_hook.feature} +1 -1
  7. data/features/{before_and_after_blocks/before_and_after_blocks.feature → hooks/before_and_after_hooks.feature} +3 -3
  8. data/features/hooks/halt.feature +27 -0
  9. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  10. data/features/mock_framework_integration/use_mocha.feature +1 -1
  11. data/features/mock_framework_integration/use_rr.feature +1 -1
  12. data/features/mock_framework_integration/use_rspec.feature +1 -1
  13. data/features/mocks/block_local_expectations.feature +2 -2
  14. data/features/mocks/mix_stubs_and_mocks.feature +1 -1
  15. data/lib/rspec/core.rb +6 -0
  16. data/lib/rspec/core/around_proxy.rb +14 -0
  17. data/lib/rspec/core/deprecation.rb +25 -26
  18. data/lib/rspec/core/example.rb +11 -21
  19. data/lib/rspec/core/example_group.rb +27 -22
  20. data/lib/rspec/core/runner.rb +12 -12
  21. data/lib/rspec/core/version.rb +1 -1
  22. data/rspec-core.gemspec +13 -11
  23. data/spec/rspec/core/configuration_spec.rb +2 -4
  24. data/spec/rspec/core/example_group_spec.rb +263 -292
  25. data/spec/rspec/core/example_group_subject_spec.rb +26 -31
  26. data/spec/rspec/core/mocha_spec.rb +8 -10
  27. data/spec/rspec/core/pending_example_spec.rb +1 -1
  28. data/spec/rspec/core/runner_spec.rb +2 -2
  29. data/spec/rspec/core/shared_example_group_spec.rb +120 -129
  30. data/spec/rspec/core/world_spec.rb +111 -116
  31. data/spec/rspec/core_spec.rb +2 -2
  32. data/spec/spec_helper.rb +2 -23
  33. metadata +9 -7
@@ -17,7 +17,7 @@ module Rspec
17
17
  Rspec::Core.configuration
18
18
  end
19
19
 
20
- def formatter
20
+ def reporter
21
21
  configuration.formatter
22
22
  end
23
23
 
@@ -32,28 +32,28 @@ module Rspec
32
32
 
33
33
  total_examples_to_run = Rspec::Core.world.total_examples_to_run
34
34
 
35
- old_sync, formatter.output.sync = formatter.output.sync, true if formatter.output.respond_to?(:sync=)
35
+ old_sync, reporter.output.sync = reporter.output.sync, true if reporter.output.respond_to?(:sync=)
36
36
 
37
37
  suite_success = true
38
38
 
39
- formatter_supports_sync = formatter.output.respond_to?(:sync=)
40
- old_sync, formatter.output.sync = formatter.output.sync, true if formatter_supports_sync
39
+ reporter_supports_sync = reporter.output.respond_to?(:sync=)
40
+ old_sync, reporter.output.sync = reporter.output.sync, true if reporter_supports_sync
41
41
 
42
- formatter.start(total_examples_to_run) # start the clock
42
+ reporter.start(total_examples_to_run) # start the clock
43
43
  start = Time.now
44
44
 
45
45
  Rspec::Core.world.example_groups_to_run.each do |example_group|
46
- suite_success &= example_group.run(formatter)
46
+ suite_success &= example_group.run(reporter)
47
47
  end
48
48
 
49
- formatter.start_dump(Time.now - start)
49
+ reporter.start_dump(Time.now - start)
50
50
 
51
- formatter.dump_failures
52
- formatter.dump_summary
53
- formatter.dump_pending
54
- formatter.close
51
+ reporter.dump_failures
52
+ reporter.dump_summary
53
+ reporter.dump_pending
54
+ reporter.close
55
55
 
56
- formatter.output.sync = old_sync if formatter_supports_sync
56
+ reporter.output.sync = old_sync if reporter_supports_sync
57
57
 
58
58
  suite_success
59
59
  end
@@ -5,7 +5,7 @@ module Rspec # :nodoc:
5
5
  MAJOR = 2
6
6
  MINOR = 0
7
7
  TINY = 0
8
- PRE = 'a5'
8
+ PRE = 'a6'
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
11
11
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-core}
8
- s.version = "2.0.0.a5"
8
+ s.version = "2.0.0.a6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chad Humphries", "David Chelimsky"]
12
- s.date = %q{2010-02-07}
12
+ s.date = %q{2010-02-15}
13
13
  s.default_executable = %q{rspec}
14
14
  s.description = %q{Rspec runner and example group classes}
15
15
  s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
@@ -91,8 +91,6 @@ Gem::Specification.new do |s|
91
91
  "features-pending/mocks/stub_implementation.feature",
92
92
  "features-pending/pending/pending_examples.feature",
93
93
  "features-pending/runner/specify_line_number.feature",
94
- "features/before_and_after_blocks/around.feature",
95
- "features/before_and_after_blocks/before_and_after_blocks.feature",
96
94
  "features/command_line/example_name_option.feature",
97
95
  "features/command_line/line_number_appended_to_path.feature",
98
96
  "features/command_line/line_number_option.feature",
@@ -100,6 +98,9 @@ Gem::Specification.new do |s|
100
98
  "features/example_groups/describe_aliases.feature",
101
99
  "features/example_groups/nested_groups.feature",
102
100
  "features/expectations/customized_message.feature",
101
+ "features/hooks/around_hook.feature",
102
+ "features/hooks/before_and_after_hooks.feature",
103
+ "features/hooks/halt.feature",
103
104
  "features/matchers/define_matcher.feature",
104
105
  "features/matchers/define_matcher_outside_rspec.feature",
105
106
  "features/mock_framework_integration/use_flexmock.feature",
@@ -116,6 +117,7 @@ Gem::Specification.new do |s|
116
117
  "lib/rspec/autorun.rb",
117
118
  "lib/rspec/core.rb",
118
119
  "lib/rspec/core/advice.rb",
120
+ "lib/rspec/core/around_proxy.rb",
119
121
  "lib/rspec/core/backward_compatibility.rb",
120
122
  "lib/rspec/core/command_line_options.rb",
121
123
  "lib/rspec/core/configuration.rb",
@@ -176,7 +178,7 @@ Gem::Specification.new do |s|
176
178
  s.require_paths = ["lib"]
177
179
  s.rubyforge_project = %q{rspec}
178
180
  s.rubygems_version = %q{1.3.5}
179
- s.summary = %q{rspec-core 2.0.0.a5}
181
+ s.summary = %q{rspec-core 2.0.0.a6}
180
182
  s.test_files = [
181
183
  "spec/rspec/core/command_line_options_spec.rb",
182
184
  "spec/rspec/core/configuration_spec.rb",
@@ -209,17 +211,17 @@ Gem::Specification.new do |s|
209
211
  s.specification_version = 3
210
212
 
211
213
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
212
- s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.a5"])
213
- s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.a5"])
214
+ s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.a6"])
215
+ s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
214
216
  s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
215
217
  else
216
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.a5"])
217
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a5"])
218
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.a6"])
219
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
218
220
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
219
221
  end
220
222
  else
221
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.a5"])
222
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a5"])
223
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.a6"])
224
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
223
225
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
224
226
  end
225
227
  end
@@ -133,7 +133,7 @@ describe Rspec::Core::Configuration do
133
133
  it "should include the given module into each matching example group" do
134
134
  Rspec::Core.configuration.include(InstanceLevelMethods, :magic_key => :include)
135
135
 
136
- group = isolated_example_group('does like, stuff and junk', :magic_key => :include) { }
136
+ group = Rspec::Core::ExampleGroup.create('does like, stuff and junk', :magic_key => :include) { }
137
137
  group.should_not respond_to(:you_call_this_a_blt?)
138
138
  group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
139
139
  end
@@ -151,10 +151,8 @@ describe Rspec::Core::Configuration do
151
151
 
152
152
  it "should extend the given module into each matching example group" do
153
153
  Rspec::Core.configuration.extend(ThatThingISentYou, :magic_key => :extend)
154
- group = Rspec::Core::ExampleGroup.describe(ThatThingISentYou, :magic_key => :extend) { }
155
-
154
+ group = Rspec::Core::ExampleGroup.create(ThatThingISentYou, :magic_key => :extend) { }
156
155
  group.should respond_to(:that_thing)
157
- remove_last_example_group_from_world
158
156
  end
159
157
 
160
158
  end
@@ -1,414 +1,385 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rspec::Core::ExampleGroup do
3
+ module Rspec::Core
4
4
 
5
- describe "#describe" do
5
+ describe ExampleGroup do
6
6
 
7
- it "raises an ArgumentError if no type or description is given" do
8
- lambda { Rspec::Core::ExampleGroup.describe() {} }.should raise_error(ArgumentError, "No arguments given. You must a least supply a type or description")
9
- end
7
+ describe "#describe" do
10
8
 
11
- it "raises an ArgumentError if no block is given" do
12
- lambda { Rspec::Core::ExampleGroup.describe('foo') }.should raise_error(ArgumentError, "You must supply a block when calling describe")
13
- end
9
+ it "raises an ArgumentError if no type or description is given" do
10
+ lambda { ExampleGroup.describe() {} }.should raise_error(ArgumentError, "No arguments given. You must a least supply a type or description")
11
+ end
14
12
 
15
- end
13
+ it "raises an ArgumentError if no block is given" do
14
+ lambda { ExampleGroup.describe('foo') }.should raise_error(ArgumentError, "You must supply a block when calling describe")
15
+ end
16
+
17
+ end
16
18
 
17
- describe '#name' do
19
+ describe '#name' do
18
20
 
19
- it "uses the first parameter as name" do
20
- disconnect_from_world do
21
- Rspec::Core::ExampleGroup.describe("my favorite pony") { }.name.should == 'my favorite pony'
21
+ it "uses the first parameter as name" do
22
+ ExampleGroup.create("my favorite pony") { }.name.should == 'my favorite pony'
22
23
  end
23
- end
24
24
 
25
- it "accepts a constant as the first parameter" do
26
- disconnect_from_world do
27
- Rspec::Core::ExampleGroup.describe(Object) { }.name.should == 'Object'
25
+ it "accepts a constant as the first parameter" do
26
+ ExampleGroup.create(Object) { }.name.should == 'Object'
28
27
  end
29
- end
30
28
 
31
- it "concats nested names" do
32
- group = isolated_example_group(Object, 'test')
33
- group.name.should == 'Object test'
29
+ it "concats nested names" do
30
+ group = ExampleGroup.create(Object, 'test') {}
31
+ group.name.should == 'Object test'
34
32
 
35
- nested_group_one = group.describe('nested one') { }
36
- nested_group_one.name.should == 'Object test nested one'
33
+ nested_group_one = group.describe('nested one') { }
34
+ nested_group_one.name.should == 'Object test nested one'
37
35
 
38
- nested_group_two = nested_group_one.describe('nested two') { }
39
- nested_group_two.name.should == 'Object test nested one nested two'
40
- end
36
+ nested_group_two = nested_group_one.describe('nested two') { }
37
+ nested_group_two.name.should == 'Object test nested one nested two'
38
+ end
41
39
 
42
- end
40
+ end
43
41
 
44
- describe '#describes' do
42
+ describe '#describes' do
45
43
 
46
- context "with a constant as the first parameter" do
44
+ context "with a constant as the first parameter" do
47
45
 
48
- it "is that constant" do
49
- disconnect_from_world do
50
- Rspec::Core::ExampleGroup.describe(Object) { }.describes.should == Object
46
+ it "is that constant" do
47
+ ExampleGroup.create(Object) { }.describes.should == Object
51
48
  end
52
- end
53
49
 
54
- end
50
+ end
55
51
 
56
- context "with a string as the first parameter" do
52
+ context "with a string as the first parameter" do
57
53
 
58
- it "is nil" do
59
- disconnect_from_world do
60
- Rspec::Core::ExampleGroup.describe("i'm a computer") { }.describes.should be_nil
54
+ it "is nil" do
55
+ ExampleGroup.create("i'm a computer") { }.describes.should be_nil
61
56
  end
57
+
62
58
  end
63
59
 
64
60
  end
65
61
 
66
- end
67
-
68
- describe '#description' do
62
+ describe '#description' do
69
63
 
70
- it "exposes the second parameter as description" do
71
- disconnect_from_world do
72
- Rspec::Core::ExampleGroup.describe(Object, "my desc") { }.description.should == 'my desc'
64
+ it "exposes the second parameter as description" do
65
+ ExampleGroup.create(Object, "my desc") { }.description.should == 'my desc'
73
66
  end
74
- end
75
67
 
76
- it "allows the second parameter to be nil" do
77
- disconnect_from_world do
78
- Rspec::Core::ExampleGroup.describe(Object, nil) { }.description.should == ""
68
+ it "allows the second parameter to be nil" do
69
+ ExampleGroup.create(Object, nil) { }.description.should == ""
79
70
  end
80
- end
81
71
 
82
- end
72
+ end
83
73
 
84
- describe '#metadata' do
74
+ describe '#metadata' do
85
75
 
86
- it "adds the third parameter to the metadata" do
87
- disconnect_from_world do
88
- Rspec::Core::ExampleGroup.describe(Object, nil, 'foo' => 'bar') { }.metadata.should include({ "foo" => 'bar' })
76
+ it "adds the third parameter to the metadata" do
77
+ ExampleGroup.create(Object, nil, 'foo' => 'bar') { }.metadata.should include({ "foo" => 'bar' })
89
78
  end
90
- end
91
79
 
92
- it "adds the caller to metadata" do
93
- disconnect_from_world do
94
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:caller].any? {|f|
80
+ it "adds the caller to metadata" do
81
+ ExampleGroup.create(Object) { }.metadata[:example_group][:caller].any? {|f|
95
82
  f =~ /#{__FILE__}/
96
83
  }.should be_true
97
84
  end
98
- end
99
85
 
100
- it "adds the the file_path to metadata" do
101
- disconnect_from_world do
102
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path].should == __FILE__
86
+ it "adds the the file_path to metadata" do
87
+ ExampleGroup.create(Object) { }.metadata[:example_group][:file_path].should == __FILE__
103
88
  end
104
- end
105
89
 
106
- it "has a reader for file_path" do
107
- disconnect_from_world do
108
- Rspec::Core::ExampleGroup.describe(Object) { }.file_path.should == __FILE__
90
+ it "has a reader for file_path" do
91
+ ExampleGroup.create(Object) { }.file_path.should == __FILE__
109
92
  end
110
- end
111
93
 
112
- it "adds the line_number to metadata" do
113
- disconnect_from_world do
114
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number].should == __LINE__
94
+ it "adds the line_number to metadata" do
95
+ ExampleGroup.create(Object) { }.metadata[:example_group][:line_number].should == __LINE__
115
96
  end
97
+
116
98
  end
117
99
 
118
- it "adds file path and line number metadata for arbitrarily nested describes" do
119
- Rspec::Core::ExampleGroup.describe(Object) do
120
- Rspec::Core::ExampleGroup.describe("foo") do
121
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path].should == __FILE__
122
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number].should == __LINE__
123
- end
124
- end
100
+ describe "adding before, after, and around hooks" do
125
101
 
126
- 4.times { remove_last_example_group_from_world }
127
- end
102
+ it "should expose the before each blocks at before_eachs" do
103
+ group = ExampleGroup.create
104
+ group.before(:each) { 'foo' }
105
+ group.should have(1).before_eachs
106
+ end
128
107
 
129
- end
108
+ it "should maintain the before each block order" do
109
+ group = ExampleGroup.create
110
+ group.before(:each) { 15 }
111
+ group.before(:each) { 'A' }
112
+ group.before(:each) { 33.5 }
130
113
 
131
- describe "adding before, after, and around hooks" do
114
+ group.before_eachs[0].call.should == 15
115
+ group.before_eachs[1].call.should == 'A'
116
+ group.before_eachs[2].call.should == 33.5
117
+ end
132
118
 
133
- it "should expose the before each blocks at before_eachs" do
134
- group = isolated_example_group
135
- group.before(:each) { 'foo' }
136
- group.should have(1).before_eachs
137
- end
119
+ it "should expose the before all blocks at before_alls" do
120
+ group = ExampleGroup.create
121
+ group.before(:all) { 'foo' }
122
+ group.should have(1).before_alls
123
+ end
138
124
 
139
- it "should maintain the before each block order" do
140
- group = isolated_example_group
141
- group.before(:each) { 15 }
142
- group.before(:each) { 'A' }
143
- group.before(:each) { 33.5 }
125
+ it "should maintain the before all block order" do
126
+ group = ExampleGroup.create
127
+ group.before(:all) { 15 }
128
+ group.before(:all) { 'A' }
129
+ group.before(:all) { 33.5 }
144
130
 
145
- group.before_eachs[0].call.should == 15
146
- group.before_eachs[1].call.should == 'A'
147
- group.before_eachs[2].call.should == 33.5
148
- end
131
+ group.before_alls[0].call.should == 15
132
+ group.before_alls[1].call.should == 'A'
133
+ group.before_alls[2].call.should == 33.5
134
+ end
149
135
 
150
- it "should expose the before all blocks at before_alls" do
151
- group = isolated_example_group
152
- group.before(:all) { 'foo' }
153
- group.should have(1).before_alls
154
- end
136
+ it "should expose the after each blocks at after_eachs" do
137
+ group = ExampleGroup.create
138
+ group.after(:each) { 'foo' }
139
+ group.should have(1).after_eachs
140
+ end
155
141
 
156
- it "should maintain the before all block order" do
157
- group = isolated_example_group
158
- group.before(:all) { 15 }
159
- group.before(:all) { 'A' }
160
- group.before(:all) { 33.5 }
142
+ it "should maintain the after each block order" do
143
+ group = ExampleGroup.create
144
+ group.after(:each) { 15 }
145
+ group.after(:each) { 'A' }
146
+ group.after(:each) { 33.5 }
161
147
 
162
- group.before_alls[0].call.should == 15
163
- group.before_alls[1].call.should == 'A'
164
- group.before_alls[2].call.should == 33.5
165
- end
148
+ group.after_eachs[0].call.should == 15
149
+ group.after_eachs[1].call.should == 'A'
150
+ group.after_eachs[2].call.should == 33.5
151
+ end
166
152
 
167
- it "should expose the after each blocks at after_eachs" do
168
- group = isolated_example_group
169
- group.after(:each) { 'foo' }
170
- group.should have(1).after_eachs
171
- end
153
+ it "should expose the after all blocks at after_alls" do
154
+ group = ExampleGroup.create
155
+ group.after(:all) { 'foo' }
156
+ group.should have(1).after_alls
157
+ end
172
158
 
173
- it "should maintain the after each block order" do
174
- group = isolated_example_group
175
- group.after(:each) { 15 }
176
- group.after(:each) { 'A' }
177
- group.after(:each) { 33.5 }
159
+ it "should maintain the after each block order" do
160
+ group = ExampleGroup.create
161
+ group.after(:all) { 15 }
162
+ group.after(:all) { 'A' }
163
+ group.after(:all) { 33.5 }
178
164
 
179
- group.after_eachs[0].call.should == 15
180
- group.after_eachs[1].call.should == 'A'
181
- group.after_eachs[2].call.should == 33.5
182
- end
165
+ group.after_alls[0].call.should == 15
166
+ group.after_alls[1].call.should == 'A'
167
+ group.after_alls[2].call.should == 33.5
168
+ end
183
169
 
184
- it "should expose the after all blocks at after_alls" do
185
- group = isolated_example_group
186
- group.after(:all) { 'foo' }
187
- group.should have(1).after_alls
170
+ it "should expose the around each blocks at after_alls" do
171
+ group = ExampleGroup.create
172
+ group.around(:each) { 'foo' }
173
+ group.should have(1).around_eachs
174
+ end
175
+
188
176
  end
189
177
 
190
- it "should maintain the after each block order" do
191
- group = isolated_example_group
192
- group.after(:all) { 15 }
193
- group.after(:all) { 'A' }
194
- group.after(:all) { 33.5 }
178
+ describe "adding examples" do
195
179
 
196
- group.after_alls[0].call.should == 15
197
- group.after_alls[1].call.should == 'A'
198
- group.after_alls[2].call.should == 33.5
199
- end
180
+ it "should allow adding an example using 'it'" do
181
+ group = ExampleGroup.create
182
+ group.it("should do something") { }
183
+ group.examples.size.should == 1
184
+ end
200
185
 
201
- it "should expose the around each blocks at after_alls" do
202
- group = isolated_example_group
203
- group.around(:each) { 'foo' }
204
- group.should have(1).around_eachs
205
- end
206
-
207
- end
186
+ it "should expose all examples at examples" do
187
+ group = ExampleGroup.create
188
+ group.it("should do something 1") { }
189
+ group.it("should do something 2") { }
190
+ group.it("should do something 3") { }
191
+ group.examples.size.should == 3
192
+ end
208
193
 
209
- describe "adding examples" do
194
+ it "should maintain the example order" do
195
+ group = ExampleGroup.create
196
+ group.it("should 1") { }
197
+ group.it("should 2") { }
198
+ group.it("should 3") { }
199
+ group.examples[0].description.should == 'should 1'
200
+ group.examples[1].description.should == 'should 2'
201
+ group.examples[2].description.should == 'should 3'
202
+ end
210
203
 
211
- it "should allow adding an example using 'it'" do
212
- group = isolated_example_group
213
- group.it("should do something") { }
214
- group.examples.size.should == 1
215
204
  end
216
205
 
217
- it "should expose all examples at examples" do
218
- group = isolated_example_group
219
- group.it("should do something 1") { }
220
- group.it("should do something 2") { }
221
- group.it("should do something 3") { }
222
- group.examples.size.should == 3
223
- end
206
+ describe Object, "describing nested example_groups", :little_less_nested => 'yep' do
224
207
 
225
- it "should maintain the example order" do
226
- group = isolated_example_group
227
- group.it("should 1") { }
228
- group.it("should 2") { }
229
- group.it("should 3") { }
230
- group.examples[0].description.should == 'should 1'
231
- group.examples[1].description.should == 'should 2'
232
- group.examples[2].description.should == 'should 3'
233
- end
208
+ describe "A sample nested group", :nested_describe => "yep" do
209
+ it "sets the described class to the constant Object" do
210
+ running_example.example_group.describes.should == Object
211
+ end
234
212
 
235
- end
213
+ it "sets the description to 'A sample nested describe'" do
214
+ running_example.example_group.description.should == 'A sample nested group'
215
+ end
236
216
 
237
- describe Object, "describing nested example_groups", :little_less_nested => 'yep' do
217
+ it "has top level metadata from the example_group and its ancestors" do
218
+ running_example.example_group.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep')
219
+ end
238
220
 
239
- describe "A sample nested group", :nested_describe => "yep" do
240
- it "sets the described class to the constant Object" do
241
- running_example.example_group.describes.should == Object
221
+ it "exposes the parent metadata to the contained examples" do
222
+ running_example.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep')
223
+ end
242
224
  end
243
225
 
244
- it "sets the description to 'A sample nested describe'" do
245
- running_example.example_group.description.should == 'A sample nested group'
226
+ end
227
+
228
+ describe "#run_examples" do
229
+ before do
230
+ @fake_formatter = Formatters::BaseFormatter.new
246
231
  end
247
232
 
248
- it "has top level metadata from the example_group and its ancestors" do
249
- running_example.example_group.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep')
233
+ def stub_example_group
234
+ stub('example_group',
235
+ :metadata => Metadata.new.process(
236
+ 'example_group_name',
237
+ :caller => ['foo_spec.rb:37']
238
+ )
239
+ ).as_null_object
250
240
  end
251
241
 
252
- it "exposes the parent metadata to the contained examples" do
253
- running_example.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep')
242
+ it "should return true if all examples pass" do
243
+ use_formatter(@fake_formatter) do
244
+ passing_example1 = Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
245
+ passing_example2 = Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
246
+ ExampleGroup.stub(:examples_to_run).and_return([passing_example1, passing_example2])
247
+
248
+ ExampleGroup.run_examples(stub_example_group, mock('reporter').as_null_object).should be_true
249
+ end
254
250
  end
255
- end
256
251
 
257
- end
252
+ it "should return false if any of the examples return false" do
253
+ use_formatter(@fake_formatter) do
254
+ failing_example = Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 2 }))
255
+ passing_example = Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
256
+ ExampleGroup.stub!(:examples_to_run).and_return([failing_example, passing_example])
258
257
 
259
- describe "#run_examples" do
260
- before do
261
- @fake_formatter = Rspec::Core::Formatters::BaseFormatter.new
262
- end
258
+ ExampleGroup.run_examples(stub_example_group, mock('reporter').as_null_object).should be_false
259
+ end
260
+ end
263
261
 
264
- def stub_example_group
265
- stub('example_group',
266
- :metadata => Rspec::Core::Metadata.new.process(
267
- 'example_group_name',
268
- :caller => ['foo_spec.rb:37']
269
- )
270
- ).as_null_object
271
- end
262
+ it "should run all examples, regardless of any of them failing" do
263
+ use_formatter(@fake_formatter) do
264
+ failing_example = Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 2 }))
265
+ passing_example = Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
266
+ ExampleGroup.stub!(:examples_to_run).and_return([failing_example, passing_example])
272
267
 
273
- it "should return true if all examples pass" do
274
- use_formatter(@fake_formatter) do
275
- passing_example1 = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
276
- passing_example2 = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
277
- Rspec::Core::ExampleGroup.stub!(:examples_to_run).and_return([passing_example1, passing_example2])
268
+ passing_example.should_receive(:run)
278
269
 
279
- Rspec::Core::ExampleGroup.run_examples(stub_example_group, mock('reporter').as_null_object).should be_true
270
+ ExampleGroup.run_examples(stub_example_group, mock('reporter', :null_object => true))
271
+ end
280
272
  end
273
+
281
274
  end
282
275
 
283
- it "should return false if any of the examples return false" do
284
- use_formatter(@fake_formatter) do
285
- failing_example = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 2 }))
286
- passing_example = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
287
- Rspec::Core::ExampleGroup.stub!(:examples_to_run).and_return([failing_example, passing_example])
276
+ describe "how instance variables inherit" do
277
+ before(:all) do
278
+ @before_all_top_level = 'before_all_top_level'
279
+ end
288
280
 
289
- Rspec::Core::ExampleGroup.run_examples(stub_example_group, mock('reporter').as_null_object).should be_false
281
+ before(:each) do
282
+ @before_each_top_level = 'before_each_top_level'
290
283
  end
291
- end
292
284
 
293
- it "should run all examples, regardless of any of them failing" do
294
- use_formatter(@fake_formatter) do
295
- failing_example = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 2 }))
296
- passing_example = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
297
- Rspec::Core::ExampleGroup.stub!(:examples_to_run).and_return([failing_example, passing_example])
285
+ it "should be able to access a before each ivar at the same level" do
286
+ @before_each_top_level.should == 'before_each_top_level'
287
+ end
298
288
 
299
- passing_example.should_receive(:run)
289
+ it "should be able to access a before all ivar at the same level" do
290
+ @before_all_top_level.should == 'before_all_top_level'
291
+ end
300
292
 
301
- Rspec::Core::ExampleGroup.run_examples(stub_example_group, mock('reporter', :null_object => true))
293
+ it "should be able to access the before all ivars in the before_all_ivars hash" do
294
+ with_ruby('1.8') do
295
+ running_example.example_group.before_all_ivars.should include('@before_all_top_level' => 'before_all_top_level')
296
+ end
297
+ with_ruby('1.9') do
298
+ running_example.example_group.before_all_ivars.should include(:@before_all_top_level => 'before_all_top_level')
299
+ end
302
300
  end
303
- end
304
301
 
305
- end
302
+ describe "but now I am nested" do
303
+ it "should be able to access a parent example groups before each ivar at a nested level" do
304
+ @before_each_top_level.should == 'before_each_top_level'
305
+ end
306
306
 
307
- describe "how instance variables inherit" do
308
- before(:all) do
309
- @before_all_top_level = 'before_all_top_level'
310
- end
307
+ it "should be able to access a parent example groups before all ivar at a nested level" do
308
+ @before_all_top_level.should == "before_all_top_level"
309
+ end
311
310
 
312
- before(:each) do
313
- @before_each_top_level = 'before_each_top_level'
314
- end
311
+ it "changes to before all ivars from within an example do not persist outside the current describe" do
312
+ @before_all_top_level = "ive been changed"
313
+ end
315
314
 
316
- it "should be able to access a before each ivar at the same level" do
317
- @before_each_top_level.should == 'before_each_top_level'
318
- end
315
+ describe "accessing a before_all ivar that was changed in a parent example_group" do
316
+ it "does not have access to the modified version" do
317
+ @before_all_top_level.should == 'before_all_top_level'
318
+ end
319
+ end
320
+ end
319
321
 
320
- it "should be able to access a before all ivar at the same level" do
321
- @before_all_top_level.should == 'before_all_top_level'
322
322
  end
323
323
 
324
- it "should be able to access the before all ivars in the before_all_ivars hash" do
325
- with_ruby('1.8') do
326
- running_example.example_group.before_all_ivars.should include('@before_all_top_level' => 'before_all_top_level')
324
+ describe "ivars are not shared across examples" do
325
+ it "(first example)" do
326
+ @a = 1
327
+ @b.should be_nil
327
328
  end
328
- with_ruby('1.9') do
329
- running_example.example_group.before_all_ivars.should include(:@before_all_top_level => 'before_all_top_level')
330
- end
331
- end
332
329
 
333
- describe "but now I am nested" do
334
- it "should be able to access a parent example groups before each ivar at a nested level" do
335
- @before_each_top_level.should == 'before_each_top_level'
330
+ it "(second example)" do
331
+ @b = 2
332
+ @a.should be_nil
336
333
  end
334
+ end
337
335
 
338
- it "should be able to access a parent example groups before all ivar at a nested level" do
339
- @before_all_top_level.should == "before_all_top_level"
336
+ describe "#let" do
337
+ let(:counter) do
338
+ Class.new do
339
+ def initialize
340
+ @count = 0
341
+ end
342
+ def count
343
+ @count += 1
344
+ end
345
+ end.new
340
346
  end
341
347
 
342
- it "changes to before all ivars from within an example do not persist outside the current describe" do
343
- @before_all_top_level = "ive been changed"
348
+ it "generates an instance method" do
349
+ counter.count.should == 1
344
350
  end
345
351
 
346
- describe "accessing a before_all ivar that was changed in a parent example_group" do
347
- it "does not have access to the modified version" do
348
- @before_all_top_level.should == 'before_all_top_level'
349
- end
352
+ it "caches the value" do
353
+ counter.count.should == 1
354
+ counter.count.should == 2
350
355
  end
351
356
  end
352
357
 
353
- end
354
-
355
- describe "ivars are not shared across examples" do
356
- it "(first example)" do
357
- @a = 1
358
- @b.should be_nil
359
- end
360
-
361
- it "(second example)" do
362
- @b = 2
363
- @a.should be_nil
364
- end
365
- end
358
+ describe "#around" do
359
+ class Thing
360
+ def self.cache
361
+ @cache ||= []
362
+ end
366
363
 
367
- describe "#let" do
368
- let(:counter) do
369
- Class.new do
370
364
  def initialize
371
- @count = 0
372
- end
373
- def count
374
- @count += 1
365
+ self.class.cache << self
375
366
  end
376
- end.new
377
- end
378
-
379
- it "generates an instance method" do
380
- counter.count.should == 1
381
- end
382
-
383
- it "caches the value" do
384
- counter.count.should == 1
385
- counter.count.should == 2
386
- end
387
- end
388
-
389
- describe "#around" do
390
- class Thing
391
- def self.cache
392
- @cache ||= []
393
367
  end
394
368
 
395
- def initialize
396
- self.class.cache << self
369
+ around(:each) do |example|
370
+ Thing.new
371
+ example.run
372
+ Thing.cache.clear
397
373
  end
398
- end
399
-
400
- around(:each) do |example|
401
- Thing.new
402
- example.run
403
- Thing.cache.clear
404
- end
405
374
 
406
- it "has 1 Thing (1)" do
407
- Thing.cache.length.should == 1
408
- end
375
+ it "has 1 Thing (1)" do
376
+ Thing.cache.length.should == 1
377
+ end
409
378
 
410
- it "has 1 Thing (2)" do
411
- Thing.cache.length.should == 1
379
+ it "has 1 Thing (2)" do
380
+ Thing.cache.length.should == 1
381
+ end
412
382
  end
413
383
  end
384
+
414
385
  end