rspec-core 2.0.0.beta.7 → 2.0.0.beta.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/cucumber.yml +1 -1
- data/features/hooks/before_and_after_hooks.feature +42 -16
- data/features/pending/pending_examples.feature +6 -6
- data/features/subject/explicit_subject.feature +2 -3
- data/features/subject/implicit_subject.feature +0 -4
- data/features/support/env.rb +1 -1
- data/lib/rspec/core.rb +2 -0
- data/lib/rspec/core/errors.rb +14 -0
- data/lib/rspec/core/example.rb +57 -64
- data/lib/rspec/core/example_group.rb +61 -66
- data/lib/rspec/core/formatters/base_text_formatter.rb +11 -8
- data/lib/rspec/core/formatters/documentation_formatter.rb +4 -4
- data/lib/rspec/core/pending.rb +19 -0
- data/lib/rspec/core/subject.rb +1 -1
- data/rspec-core.gemspec +14 -12
- data/spec/rspec/core/configuration_spec.rb +3 -3
- data/spec/rspec/core/example_group_spec.rb +70 -128
- data/spec/rspec/core/example_spec.rb +39 -17
- data/spec/rspec/core/formatters/helpers_spec.rb +5 -4
- data/spec/rspec/core/let_spec.rb +42 -0
- data/spec/rspec/core/pending_example_spec.rb +72 -6
- data/spec/rspec/core/shared_example_group_spec.rb +77 -93
- data/spec/rspec/core/subject_spec.rb +6 -6
- data/spec/rspec/core/world_spec.rb +4 -4
- data/spec/spec_helper.rb +14 -7
- metadata +13 -11
- data/spec/rspec/core/mocha_spec.rb +0 -27
@@ -11,12 +11,15 @@ module Rspec
|
|
11
11
|
failed_examples.each_with_index do |failed_example, index|
|
12
12
|
exception = failed_example.execution_result[:exception_encountered]
|
13
13
|
padding = ' '
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
output.puts "#{padding}#{
|
14
|
+
if exception.is_a?(Rspec::Core::PendingExampleFixedError)
|
15
|
+
output.puts "#{index.next}) #{failed_example} FIXED"
|
16
|
+
output.puts "#{padding}Expected pending '#{failed_example.metadata[:execution_result][:pending_message]}' to fail. No Error was raised."
|
17
|
+
else
|
18
|
+
output.puts "#{index.next}) #{failed_example}"
|
19
|
+
output.puts "#{padding}Failure/Error: #{read_failed_line(exception, failed_example).strip}"
|
20
|
+
exception.message.split("\n").each do |line|
|
21
|
+
output.puts "#{padding}#{colorise(line, exception).strip}"
|
22
|
+
end
|
20
23
|
end
|
21
24
|
|
22
25
|
format_backtrace(exception.backtrace, failed_example).each do |backtrace_info|
|
@@ -73,8 +76,8 @@ module Rspec
|
|
73
76
|
unless pending_examples.empty?
|
74
77
|
output.puts
|
75
78
|
output.puts "Pending:"
|
76
|
-
pending_examples.each do |pending_example
|
77
|
-
output.puts " #{pending_example}"
|
79
|
+
pending_examples.each do |pending_example|
|
80
|
+
output.puts " #{pending_example} (#{pending_example.metadata[:execution_result][:pending_message]})"
|
78
81
|
output.puts grey(" # #{format_caller(pending_example.metadata[:location])}")
|
79
82
|
end
|
80
83
|
end
|
@@ -14,14 +14,14 @@ module Rspec
|
|
14
14
|
def add_example_group(example_group)
|
15
15
|
super
|
16
16
|
|
17
|
-
|
17
|
+
example_group_chain.each_with_index do |nested_example_group, i|
|
18
18
|
unless nested_example_group == @previous_nested_example_groups[i]
|
19
19
|
output.puts if i == 0
|
20
20
|
output.puts "#{' ' * i}#{nested_example_group.description}"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
@previous_nested_example_groups =
|
24
|
+
@previous_nested_example_groups = example_group_chain
|
25
25
|
end
|
26
26
|
|
27
27
|
def output_for(example)
|
@@ -67,8 +67,8 @@ module Rspec
|
|
67
67
|
' ' * @previous_nested_example_groups.size
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
example_group.ancestors
|
70
|
+
def example_group_chain
|
71
|
+
example_group.ancestors.reverse
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Rspec
|
2
|
+
module Core
|
3
|
+
module Pending
|
4
|
+
def pending(message = 'No reason given')
|
5
|
+
running_example.metadata[:pending] = true
|
6
|
+
running_example.metadata[:execution_result][:pending_message] = message
|
7
|
+
if block_given?
|
8
|
+
begin
|
9
|
+
result = yield
|
10
|
+
running_example.metadata[:pending] = false
|
11
|
+
rescue Exception => e
|
12
|
+
end
|
13
|
+
raise Rspec::Core::PendingExampleFixedError.new if result
|
14
|
+
end
|
15
|
+
throw :pending_declared_in_example, message
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/rspec/core/subject.rb
CHANGED
data/rspec-core.gemspec
CHANGED
@@ -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.beta.
|
8
|
+
s.version = "2.0.0.beta.8"
|
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-04-
|
12
|
+
s.date = %q{2010-04-27}
|
13
13
|
s.description = %q{Rspec runner and example group classes}
|
14
14
|
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
15
15
|
s.executables = ["rspec", "spec"]
|
@@ -105,6 +105,7 @@ Gem::Specification.new do |s|
|
|
105
105
|
"lib/rspec/core/configuration.rb",
|
106
106
|
"lib/rspec/core/configuration_options.rb",
|
107
107
|
"lib/rspec/core/deprecation.rb",
|
108
|
+
"lib/rspec/core/errors.rb",
|
108
109
|
"lib/rspec/core/example.rb",
|
109
110
|
"lib/rspec/core/example_group.rb",
|
110
111
|
"lib/rspec/core/formatters.rb",
|
@@ -123,6 +124,7 @@ Gem::Specification.new do |s|
|
|
123
124
|
"lib/rspec/core/mocking/with_mocha.rb",
|
124
125
|
"lib/rspec/core/mocking/with_rr.rb",
|
125
126
|
"lib/rspec/core/mocking/with_rspec.rb",
|
127
|
+
"lib/rspec/core/pending.rb",
|
126
128
|
"lib/rspec/core/rake_task.rb",
|
127
129
|
"lib/rspec/core/ruby_project.rb",
|
128
130
|
"lib/rspec/core/runner.rb",
|
@@ -144,8 +146,8 @@ Gem::Specification.new do |s|
|
|
144
146
|
"spec/rspec/core/formatters/helpers_spec.rb",
|
145
147
|
"spec/rspec/core/formatters/progress_formatter_spec.rb",
|
146
148
|
"spec/rspec/core/kernel_extensions_spec.rb",
|
149
|
+
"spec/rspec/core/let_spec.rb",
|
147
150
|
"spec/rspec/core/metadata_spec.rb",
|
148
|
-
"spec/rspec/core/mocha_spec.rb",
|
149
151
|
"spec/rspec/core/pending_example_spec.rb",
|
150
152
|
"spec/rspec/core/resources/a_bar.rb",
|
151
153
|
"spec/rspec/core/resources/a_foo.rb",
|
@@ -166,7 +168,7 @@ Gem::Specification.new do |s|
|
|
166
168
|
s.homepage = %q{http://github.com/rspec/core}
|
167
169
|
s.post_install_message = %q{**************************************************
|
168
170
|
|
169
|
-
Thank you for installing rspec-core-2.0.0.beta.
|
171
|
+
Thank you for installing rspec-core-2.0.0.beta.8
|
170
172
|
|
171
173
|
This is beta software. If you are looking
|
172
174
|
for a supported production release, please
|
@@ -178,7 +180,7 @@ Gem::Specification.new do |s|
|
|
178
180
|
s.require_paths = ["lib"]
|
179
181
|
s.rubyforge_project = %q{rspec}
|
180
182
|
s.rubygems_version = %q{1.3.6}
|
181
|
-
s.summary = %q{rspec-core-2.0.0.beta.
|
183
|
+
s.summary = %q{rspec-core-2.0.0.beta.8}
|
182
184
|
s.test_files = [
|
183
185
|
"spec/autotest/failed_results_re_spec.rb",
|
184
186
|
"spec/autotest/rspec_spec.rb",
|
@@ -192,8 +194,8 @@ Gem::Specification.new do |s|
|
|
192
194
|
"spec/rspec/core/formatters/helpers_spec.rb",
|
193
195
|
"spec/rspec/core/formatters/progress_formatter_spec.rb",
|
194
196
|
"spec/rspec/core/kernel_extensions_spec.rb",
|
197
|
+
"spec/rspec/core/let_spec.rb",
|
195
198
|
"spec/rspec/core/metadata_spec.rb",
|
196
|
-
"spec/rspec/core/mocha_spec.rb",
|
197
199
|
"spec/rspec/core/pending_example_spec.rb",
|
198
200
|
"spec/rspec/core/resources/a_bar.rb",
|
199
201
|
"spec/rspec/core/resources/a_foo.rb",
|
@@ -216,19 +218,19 @@ Gem::Specification.new do |s|
|
|
216
218
|
s.specification_version = 3
|
217
219
|
|
218
220
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
219
|
-
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
220
|
-
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
221
|
+
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.8"])
|
222
|
+
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.8"])
|
221
223
|
s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
|
222
224
|
s.add_development_dependency(%q<autotest>, [">= 4.2.9"])
|
223
225
|
else
|
224
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
225
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
226
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.8"])
|
227
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.8"])
|
226
228
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
227
229
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
228
230
|
end
|
229
231
|
else
|
230
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
231
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
232
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.8"])
|
233
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.8"])
|
232
234
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
233
235
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
234
236
|
end
|
@@ -136,7 +136,7 @@ module Rspec::Core
|
|
136
136
|
it "includes the given module into each example group" do
|
137
137
|
config.include(InstanceLevelMethods)
|
138
138
|
|
139
|
-
group = ExampleGroup.
|
139
|
+
group = ExampleGroup.describe(config, 'does like, stuff and junk', :magic_key => :include) { }
|
140
140
|
group.should_not respond_to(:you_call_this_a_blt?)
|
141
141
|
group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
|
142
142
|
end
|
@@ -147,7 +147,7 @@ module Rspec::Core
|
|
147
147
|
it "includes the given module into each matching example group" do
|
148
148
|
config.include(InstanceLevelMethods, :magic_key => :include)
|
149
149
|
|
150
|
-
group = ExampleGroup.
|
150
|
+
group = ExampleGroup.describe(config, 'does like, stuff and junk', :magic_key => :include) { }
|
151
151
|
group.should_not respond_to(:you_call_this_a_blt?)
|
152
152
|
group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
|
153
153
|
end
|
@@ -164,7 +164,7 @@ module Rspec::Core
|
|
164
164
|
|
165
165
|
it "should extend the given module into each matching example group" do
|
166
166
|
config.extend(ThatThingISentYou, :magic_key => :extend)
|
167
|
-
group = ExampleGroup.
|
167
|
+
group = ExampleGroup.describe(config, ThatThingISentYou, :magic_key => :extend) { }
|
168
168
|
group.should respond_to(:that_thing)
|
169
169
|
end
|
170
170
|
|
@@ -14,35 +14,18 @@ module Rspec::Core
|
|
14
14
|
|
15
15
|
describe ExampleGroup do
|
16
16
|
|
17
|
-
describe "#describe" do
|
18
|
-
|
19
|
-
it "raises an ArgumentError if no type or description is given" do
|
20
|
-
lambda { ExampleGroup.describe() {} }.should raise_error(ArgumentError, "No arguments given. You must a least supply a type or description")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "raises an ArgumentError if no block is given" do
|
24
|
-
lambda { ExampleGroup.describe('foo') }.should raise_error(ArgumentError, "You must supply a block when calling describe")
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
17
|
describe '#describes' do
|
31
18
|
|
32
19
|
context "with a constant as the first parameter" do
|
33
|
-
|
34
20
|
it "is that constant" do
|
35
|
-
ExampleGroup.
|
21
|
+
ExampleGroup.describe(Object) { }.describes.should == Object
|
36
22
|
end
|
37
|
-
|
38
23
|
end
|
39
24
|
|
40
25
|
context "with a string as the first parameter" do
|
41
|
-
|
42
26
|
it "is nil" do
|
43
|
-
ExampleGroup.
|
27
|
+
ExampleGroup.describe("i'm a computer") { }.describes.should be_nil
|
44
28
|
end
|
45
|
-
|
46
29
|
end
|
47
30
|
|
48
31
|
end
|
@@ -50,7 +33,7 @@ module Rspec::Core
|
|
50
33
|
describe '#description' do
|
51
34
|
|
52
35
|
it "grabs the description from the metadata" do
|
53
|
-
group = ExampleGroup.
|
36
|
+
group = ExampleGroup.describe(Object, "my desc") { }
|
54
37
|
group.description.should == group.metadata[:example_group][:description]
|
55
38
|
end
|
56
39
|
|
@@ -59,39 +42,39 @@ module Rspec::Core
|
|
59
42
|
describe '#metadata' do
|
60
43
|
|
61
44
|
it "adds the third parameter to the metadata" do
|
62
|
-
ExampleGroup.
|
45
|
+
ExampleGroup.describe(Object, nil, 'foo' => 'bar') { }.metadata.should include({ "foo" => 'bar' })
|
63
46
|
end
|
64
47
|
|
65
48
|
it "adds the caller to metadata" do
|
66
|
-
ExampleGroup.
|
49
|
+
ExampleGroup.describe(Object) { }.metadata[:example_group][:caller].any? {|f|
|
67
50
|
f =~ /#{__FILE__}/
|
68
51
|
}.should be_true
|
69
52
|
end
|
70
53
|
|
71
54
|
it "adds the the file_path to metadata" do
|
72
|
-
ExampleGroup.
|
55
|
+
ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path].should == __FILE__
|
73
56
|
end
|
74
57
|
|
75
58
|
it "has a reader for file_path" do
|
76
|
-
ExampleGroup.
|
59
|
+
ExampleGroup.describe(Object) { }.file_path.should == __FILE__
|
77
60
|
end
|
78
61
|
|
79
62
|
it "adds the line_number to metadata" do
|
80
|
-
ExampleGroup.
|
63
|
+
ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number].should == __LINE__
|
81
64
|
end
|
82
65
|
|
83
66
|
end
|
84
67
|
|
85
|
-
describe "
|
68
|
+
describe "before, after, and around hooks" do
|
86
69
|
|
87
|
-
it "
|
88
|
-
group = ExampleGroup.
|
70
|
+
it "exposes the before each blocks at before_eachs" do
|
71
|
+
group = ExampleGroup.describe
|
89
72
|
group.before(:each) { 'foo' }
|
90
73
|
group.should have(1).before_eachs
|
91
74
|
end
|
92
75
|
|
93
|
-
it "
|
94
|
-
group = ExampleGroup.
|
76
|
+
it "maintains the before each block order" do
|
77
|
+
group = ExampleGroup.describe
|
95
78
|
group.before(:each) { 15 }
|
96
79
|
group.before(:each) { 'A' }
|
97
80
|
group.before(:each) { 33.5 }
|
@@ -101,14 +84,14 @@ module Rspec::Core
|
|
101
84
|
group.before_eachs[2].call.should == 33.5
|
102
85
|
end
|
103
86
|
|
104
|
-
it "
|
105
|
-
group = ExampleGroup.
|
87
|
+
it "exposes the before all blocks at before_alls" do
|
88
|
+
group = ExampleGroup.describe
|
106
89
|
group.before(:all) { 'foo' }
|
107
90
|
group.should have(1).before_alls
|
108
91
|
end
|
109
92
|
|
110
|
-
it "
|
111
|
-
group = ExampleGroup.
|
93
|
+
it "maintains the before all block order" do
|
94
|
+
group = ExampleGroup.describe
|
112
95
|
group.before(:all) { 15 }
|
113
96
|
group.before(:all) { 'A' }
|
114
97
|
group.before(:all) { 33.5 }
|
@@ -118,14 +101,14 @@ module Rspec::Core
|
|
118
101
|
group.before_alls[2].call.should == 33.5
|
119
102
|
end
|
120
103
|
|
121
|
-
it "
|
122
|
-
group = ExampleGroup.
|
104
|
+
it "exposes the after each blocks at after_eachs" do
|
105
|
+
group = ExampleGroup.describe
|
123
106
|
group.after(:each) { 'foo' }
|
124
107
|
group.should have(1).after_eachs
|
125
108
|
end
|
126
109
|
|
127
|
-
it "
|
128
|
-
group = ExampleGroup.
|
110
|
+
it "maintains the after each block order" do
|
111
|
+
group = ExampleGroup.describe
|
129
112
|
group.after(:each) { 15 }
|
130
113
|
group.after(:each) { 'A' }
|
131
114
|
group.after(:each) { 33.5 }
|
@@ -135,14 +118,14 @@ module Rspec::Core
|
|
135
118
|
group.after_eachs[2].call.should == 33.5
|
136
119
|
end
|
137
120
|
|
138
|
-
it "
|
139
|
-
group = ExampleGroup.
|
121
|
+
it "exposes the after all blocks at after_alls" do
|
122
|
+
group = ExampleGroup.describe
|
140
123
|
group.after(:all) { 'foo' }
|
141
124
|
group.should have(1).after_alls
|
142
125
|
end
|
143
126
|
|
144
|
-
it "
|
145
|
-
group = ExampleGroup.
|
127
|
+
it "maintains the after each block order" do
|
128
|
+
group = ExampleGroup.describe
|
146
129
|
group.after(:all) { 15 }
|
147
130
|
group.after(:all) { 'A' }
|
148
131
|
group.after(:all) { 33.5 }
|
@@ -152,8 +135,8 @@ module Rspec::Core
|
|
152
135
|
group.after_alls[2].call.should == 33.5
|
153
136
|
end
|
154
137
|
|
155
|
-
it "
|
156
|
-
group = ExampleGroup.
|
138
|
+
it "exposes the around each blocks at after_alls" do
|
139
|
+
group = ExampleGroup.describe
|
157
140
|
group.around(:each) { 'foo' }
|
158
141
|
group.should have(1).around_eachs
|
159
142
|
end
|
@@ -162,22 +145,22 @@ module Rspec::Core
|
|
162
145
|
|
163
146
|
describe "adding examples" do
|
164
147
|
|
165
|
-
it "
|
166
|
-
group = ExampleGroup.
|
148
|
+
it "allows adding an example using 'it'" do
|
149
|
+
group = ExampleGroup.describe
|
167
150
|
group.it("should do something") { }
|
168
151
|
group.examples.size.should == 1
|
169
152
|
end
|
170
153
|
|
171
|
-
it "
|
172
|
-
group = ExampleGroup.
|
154
|
+
it "exposes all examples at examples" do
|
155
|
+
group = ExampleGroup.describe
|
173
156
|
group.it("should do something 1") { }
|
174
157
|
group.it("should do something 2") { }
|
175
158
|
group.it("should do something 3") { }
|
176
159
|
group.examples.size.should == 3
|
177
160
|
end
|
178
161
|
|
179
|
-
it "
|
180
|
-
group = ExampleGroup.
|
162
|
+
it "maintains the example order" do
|
163
|
+
group = ExampleGroup.describe
|
181
164
|
group.it("should 1") { }
|
182
165
|
group.it("should 2") { }
|
183
166
|
group.it("should 3") { }
|
@@ -211,54 +194,41 @@ module Rspec::Core
|
|
211
194
|
end
|
212
195
|
|
213
196
|
describe "#run_examples" do
|
214
|
-
before do
|
215
|
-
@fake_formatter = Formatters::BaseFormatter.new
|
216
|
-
end
|
217
|
-
|
218
|
-
def stub_example_group
|
219
|
-
stub('example_group',
|
220
|
-
:metadata => Metadata.new.process(
|
221
|
-
'example_group_name',
|
222
|
-
:caller => ['foo_spec.rb:37']
|
223
|
-
)
|
224
|
-
).as_null_object
|
225
|
-
end
|
226
197
|
|
227
|
-
|
228
|
-
use_formatter(@fake_formatter) do
|
229
|
-
passing_example1 = Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
|
230
|
-
passing_example2 = Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
|
231
|
-
ExampleGroup.stub(:examples_to_run).and_return([passing_example1, passing_example2])
|
198
|
+
let(:reporter) { double("reporter").as_null_object }
|
232
199
|
|
233
|
-
|
200
|
+
it "returns true if all examples pass" do
|
201
|
+
group = ExampleGroup.describe('group') do
|
202
|
+
example('ex 1') { 1.should == 1 }
|
203
|
+
example('ex 2') { 1.should == 1 }
|
234
204
|
end
|
205
|
+
group.stub(:examples_to_run) { group.examples }
|
206
|
+
group.run(reporter).should be_true
|
235
207
|
end
|
236
208
|
|
237
|
-
it "
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
ExampleGroup.stub!(:examples_to_run).and_return([failing_example, passing_example])
|
242
|
-
|
243
|
-
ExampleGroup.run_examples(stub_example_group, mock('reporter').as_null_object).should be_false
|
209
|
+
it "returns false if any of the examples fail" do
|
210
|
+
group = ExampleGroup.describe('group') do
|
211
|
+
example('ex 1') { 1.should == 1 }
|
212
|
+
example('ex 2') { 1.should == 2 }
|
244
213
|
end
|
214
|
+
group.stub(:examples_to_run) { group.examples }
|
215
|
+
group.run(reporter).should be_false
|
245
216
|
end
|
246
217
|
|
247
|
-
it "
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
ExampleGroup.stub!(:examples_to_run).and_return([failing_example, passing_example])
|
252
|
-
|
253
|
-
passing_example.should_receive(:run)
|
254
|
-
|
255
|
-
ExampleGroup.run_examples(stub_example_group, mock('reporter', :null_object => true))
|
218
|
+
it "runs all examples, regardless of any of them failing" do
|
219
|
+
group = ExampleGroup.describe('group') do
|
220
|
+
example('ex 1') { 1.should == 2 }
|
221
|
+
example('ex 2') { 1.should == 1 }
|
256
222
|
end
|
223
|
+
group.stub(:examples_to_run) { group.examples }
|
224
|
+
group.examples_to_run.each do |example|
|
225
|
+
example.should_receive(:run)
|
226
|
+
end
|
227
|
+
group.run(reporter).should be_false
|
257
228
|
end
|
258
|
-
|
259
229
|
end
|
260
230
|
|
261
|
-
describe "how instance variables
|
231
|
+
describe "how instance variables are inherited" do
|
262
232
|
before(:all) do
|
263
233
|
@before_all_top_level = 'before_all_top_level'
|
264
234
|
end
|
@@ -317,47 +287,6 @@ module Rspec::Core
|
|
317
287
|
end
|
318
288
|
end
|
319
289
|
|
320
|
-
describe "#let" do
|
321
|
-
let(:counter) do
|
322
|
-
Class.new do
|
323
|
-
def initialize
|
324
|
-
@count = 0
|
325
|
-
end
|
326
|
-
def count
|
327
|
-
@count += 1
|
328
|
-
end
|
329
|
-
end.new
|
330
|
-
end
|
331
|
-
|
332
|
-
it "generates an instance method" do
|
333
|
-
counter.count.should == 1
|
334
|
-
end
|
335
|
-
|
336
|
-
it "caches the value" do
|
337
|
-
counter.count.should == 1
|
338
|
-
counter.count.should == 2
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
describe "#let!" do
|
343
|
-
let!(:creator) do
|
344
|
-
class Creator
|
345
|
-
@count = 0
|
346
|
-
def self.count
|
347
|
-
@count += 1
|
348
|
-
end
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
it "evaluates the value non-lazily" do
|
353
|
-
lambda { Creator.count }.should_not raise_error
|
354
|
-
end
|
355
|
-
|
356
|
-
it "does not interfere between tests" do
|
357
|
-
Creator.count.should == 1
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
290
|
describe "#around" do
|
362
291
|
|
363
292
|
around(:each) do |example|
|
@@ -374,6 +303,19 @@ module Rspec::Core
|
|
374
303
|
SelfObserver.cache.length.should == 1
|
375
304
|
end
|
376
305
|
end
|
377
|
-
end
|
378
306
|
|
307
|
+
describe "top_level_description" do
|
308
|
+
it "returns the description from the outermost example group" do
|
309
|
+
group = nil
|
310
|
+
ExampleGroup.describe("top") do
|
311
|
+
context "middle" do
|
312
|
+
group = describe "bottom" do
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
group.top_level_description.should == "top"
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
379
321
|
end
|