rspec 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -4
- data/{History.txt → History.rdoc} +27 -4
- data/Manifest.txt +18 -7
- data/{README.txt → README.rdoc} +0 -0
- data/Rakefile +16 -9
- data/{Ruby1.9.markdown → Ruby1.9.rdoc} +3 -3
- data/TODO.txt +0 -7
- data/Upgrade.rdoc +110 -0
- data/features/matchers/create_matcher.feature +40 -0
- data/features/matchers/create_matcher_outside_rspec.feature +39 -0
- data/features/pending/pending_examples.feature +5 -5
- data/features/step_definitions/running_rspec.rb +13 -0
- data/features/subject/explicit_subject.feature +31 -0
- data/features/subject/implicit_subject.feature +31 -0
- data/lib/spec/adapters/mock_frameworks/flexmock.rb +1 -0
- data/lib/spec/adapters/mock_frameworks/mocha.rb +1 -0
- data/lib/spec/adapters/mock_frameworks/rr.rb +1 -0
- data/lib/spec/adapters/mock_frameworks/rspec.rb +12 -10
- data/lib/spec/dsl.rb +0 -1
- data/lib/spec/dsl/main.rb +3 -3
- data/lib/spec/example.rb +4 -3
- data/lib/spec/example/example_group_factory.rb +1 -3
- data/lib/spec/example/example_group_methods.rb +22 -28
- data/lib/spec/example/example_group_proxy.rb +64 -0
- data/lib/spec/example/example_methods.rb +8 -11
- data/lib/spec/example/example_proxy.rb +42 -0
- data/lib/spec/example/shared_example_group.rb +1 -1
- data/lib/spec/example/subject.rb +14 -3
- data/lib/spec/expectations.rb +1 -1
- data/lib/spec/expectations/differs/default.rb +46 -49
- data/lib/spec/expectations/differs/load-diff-lcs.rb +12 -0
- data/lib/spec/interop/test/unit/testcase.rb +2 -2
- data/lib/spec/matchers.rb +49 -9
- data/lib/spec/matchers/be.rb +12 -15
- data/lib/spec/matchers/change.rb +1 -0
- data/lib/spec/matchers/dsl.rb +15 -0
- data/lib/spec/matchers/have.rb +9 -8
- data/lib/spec/matchers/include.rb +2 -16
- data/lib/spec/matchers/match_array.rb +2 -14
- data/lib/spec/matchers/matcher.rb +16 -11
- data/lib/spec/matchers/pretty.rb +36 -0
- data/lib/spec/matchers/raise_error.rb +9 -8
- data/lib/spec/matchers/simple_matcher.rb +1 -0
- data/lib/spec/matchers/throw_symbol.rb +1 -1
- data/lib/spec/mocks/argument_expectation.rb +2 -0
- data/lib/spec/mocks/message_expectation.rb +2 -0
- data/lib/spec/mocks/proxy.rb +9 -10
- data/lib/spec/runner.rb +1 -0
- data/lib/spec/runner/extensions/kernel.rb +9 -0
- data/lib/spec/runner/formatter/base_formatter.rb +22 -9
- data/lib/spec/runner/formatter/html_formatter.rb +2 -1
- data/lib/spec/runner/heckle_runner.rb +1 -0
- data/lib/spec/runner/option_parser.rb +4 -1
- data/lib/spec/runner/options.rb +11 -0
- data/lib/spec/runner/spec_parser.rb +15 -22
- data/lib/spec/version.rb +4 -6
- data/spec/autotest/autotest_helper.rb +6 -1
- data/spec/spec/dsl/main_spec.rb +3 -3
- data/spec/spec/example/example_group_factory_spec.rb +11 -23
- data/spec/spec/example/example_group_methods_spec.rb +45 -20
- data/spec/spec/example/example_group_proxy_spec.rb +63 -0
- data/spec/spec/example/example_group_spec.rb +15 -0
- data/spec/spec/example/example_methods_spec.rb +5 -35
- data/spec/spec/example/example_proxy_spec.rb +47 -0
- data/spec/spec/example/nested_example_group_spec.rb +3 -3
- data/spec/spec/example/shared_example_group_spec.rb +4 -4
- data/spec/spec/example/subject_spec.rb +77 -0
- data/spec/spec/matchers/be_close_spec.rb +10 -10
- data/spec/spec/matchers/be_instance_of_spec.rb +13 -8
- data/spec/spec/matchers/be_kind_of_spec.rb +10 -8
- data/spec/spec/{dsl/matchers_spec.rb → matchers/dsl_spec.rb} +4 -4
- data/spec/spec/matchers/matcher_spec.rb +53 -1
- data/spec/spec/matchers/matchers_spec.rb +2 -0
- data/spec/spec/package/bin_spec_spec.rb +4 -4
- data/spec/spec/runner/command_line_spec.rb +2 -2
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +4 -4
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/html_formatted-1.8.4.html +1 -1
- data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +1 -1
- data/spec/spec/runner/formatter/html_formatted-1.8.5.html +1 -1
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +1 -1
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +1 -1
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +1 -1
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +1 -1
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +12 -11
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +1 -1
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +1 -1
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +1 -1
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +1 -1
- data/spec/spec/runner/option_parser_spec.rb +20 -0
- data/spec/spec/runner/options_spec.rb +23 -1
- data/spec/spec/runner/reporter_spec.rb +20 -17
- data/spec/spec/runner/spec_parser_spec.rb +1 -1
- metadata +33 -15
- data/Upgrade.markdown +0 -63
- data/lib/spec/dsl/matchers.rb +0 -13
- data/lib/spec/example/example_description.rb +0 -15
@@ -14,7 +14,7 @@ Feature: pending examples
|
|
14
14
|
Then the exit code should be 0
|
15
15
|
And the stdout should match "1 example, 0 failures, 1 pending"
|
16
16
|
And the stdout should match "Not Yet Implemented"
|
17
|
-
And the stdout should match "current_example.rb:
|
17
|
+
And the stdout should match "current_example.rb:3"
|
18
18
|
|
19
19
|
Scenario: pending implementation with spec/test/unit
|
20
20
|
Given the following spec:
|
@@ -28,7 +28,7 @@ Feature: pending examples
|
|
28
28
|
Then the exit code should be 0
|
29
29
|
And the stdout should match "1 example, 0 failures, 1 pending"
|
30
30
|
And the stdout should match "Not Yet Implemented"
|
31
|
-
And the stdout should match "current_example.rb:
|
31
|
+
And the stdout should match "current_example.rb:4"
|
32
32
|
|
33
33
|
Scenario: pending any arbitary reason, with no block
|
34
34
|
Given the following spec:
|
@@ -43,7 +43,7 @@ Feature: pending examples
|
|
43
43
|
Then the exit code should be 0
|
44
44
|
And the stdout should match "1 example, 0 failures, 1 pending"
|
45
45
|
And the stdout should match "(something else getting finished)"
|
46
|
-
And the stdout should match "current_example.rb:
|
46
|
+
And the stdout should match "current_example.rb:4"
|
47
47
|
|
48
48
|
Scenario: pending any arbitary reason, with a block
|
49
49
|
Given the following spec:
|
@@ -60,7 +60,7 @@ Feature: pending examples
|
|
60
60
|
Then the exit code should be 0
|
61
61
|
And the stdout should match "1 example, 0 failures, 1 pending"
|
62
62
|
And the stdout should match "(something else getting finished)"
|
63
|
-
And the stdout should match "current_example.rb:
|
63
|
+
And the stdout should match "current_example.rb:4"
|
64
64
|
|
65
65
|
Scenario: pending any arbitary reason, with a block that passes
|
66
66
|
Given the following spec:
|
@@ -78,4 +78,4 @@ Feature: pending examples
|
|
78
78
|
And the stdout should match "1 example, 1 failure"
|
79
79
|
And the stdout should match "FIXED"
|
80
80
|
And the stdout should match "Expected pending 'something else getting finished' to fail. No Error was raised."
|
81
|
-
And the stdout should match "current_example.rb:
|
81
|
+
And the stdout should match "current_example.rb:4"
|
@@ -10,10 +10,23 @@ Given /^the following spec:$/ do |spec|
|
|
10
10
|
FileUtils.mkdir(dir) unless test ?d, dir
|
11
11
|
@path = "#{dir}/current_example.rb"
|
12
12
|
File.open(@path, "w") do |f|
|
13
|
+
f.write %Q[$:.unshift File.join(File.dirname(__FILE__), "/../lib")]
|
14
|
+
f.write "\n"
|
13
15
|
f.write spec
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
19
|
+
Given /^a file named (.*) with:$/ do |filename, code|
|
20
|
+
dir = File.join(File.dirname(__FILE__), "/../../tmp")
|
21
|
+
FileUtils.mkdir(dir) unless test ?d, dir
|
22
|
+
@path = "#{dir}/#{filename}"
|
23
|
+
File.open(@path, "w") do |f|
|
24
|
+
f.write %Q[$:.unshift File.join(File.dirname(__FILE__), "/../lib")]
|
25
|
+
f.write "\n"
|
26
|
+
f.write code
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
17
30
|
When /^I run it with the (.*)$/ do |interpreter|
|
18
31
|
stderr_file = Tempfile.new('rspec')
|
19
32
|
stderr_file.close
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: explicit subject
|
2
|
+
|
3
|
+
You can override the implicit subject using the subject() method.
|
4
|
+
|
5
|
+
Scenario: subject in top level group
|
6
|
+
Given the following spec:
|
7
|
+
"""
|
8
|
+
describe Array, "with some elements" do
|
9
|
+
subject { [1,2,3] }
|
10
|
+
it "should have the prescribed elements" do
|
11
|
+
subject.should == [1,2,3]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
When I run it with the spec command
|
16
|
+
Then the stdout should match "1 example, 0 failures"
|
17
|
+
|
18
|
+
Scenario: subject in a nested group
|
19
|
+
Given the following spec:
|
20
|
+
"""
|
21
|
+
describe Array do
|
22
|
+
subject { [1,2,3] }
|
23
|
+
describe "with some elements" do
|
24
|
+
it "should have the prescribed elements" do
|
25
|
+
subject.should == [1,2,3]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I run it with the spec command
|
31
|
+
Then the stdout should match "1 example, 0 failures"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: implicit subject
|
2
|
+
|
3
|
+
The first argument to the outermost example group block is
|
4
|
+
made available to each example as an implicit subject of
|
5
|
+
that example.
|
6
|
+
|
7
|
+
Scenario: subject in top level group
|
8
|
+
Given the following spec:
|
9
|
+
"""
|
10
|
+
describe Array, "when first created" do
|
11
|
+
it "should be empty" do
|
12
|
+
subject.should == []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
When I run it with the spec command
|
17
|
+
Then the stdout should match "1 example, 0 failures"
|
18
|
+
|
19
|
+
Scenario: subject in a nested group
|
20
|
+
Given the following spec:
|
21
|
+
"""
|
22
|
+
describe Array do
|
23
|
+
describe "when first created" do
|
24
|
+
it "should be empty" do
|
25
|
+
subject.should == []
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I run it with the spec command
|
31
|
+
Then the stdout should match "1 example, 0 failures"
|
@@ -3,16 +3,18 @@ require 'spec/mocks/extensions'
|
|
3
3
|
|
4
4
|
module Spec
|
5
5
|
module Adapters
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
unless defined?(MockFramework)
|
7
|
+
module MockFramework
|
8
|
+
include Spec::Mocks::ExampleMethods
|
9
|
+
def setup_mocks_for_rspec
|
10
|
+
$rspec_mocks ||= Spec::Mocks::Space.new
|
11
|
+
end
|
12
|
+
def verify_mocks_for_rspec
|
13
|
+
$rspec_mocks.verify_all
|
14
|
+
end
|
15
|
+
def teardown_mocks_for_rspec
|
16
|
+
$rspec_mocks.reset_all
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/spec/dsl.rb
CHANGED
data/lib/spec/dsl/main.rb
CHANGED
@@ -20,7 +20,7 @@ module Spec
|
|
20
20
|
# register special implementations.
|
21
21
|
#
|
22
22
|
def describe(*args, &block)
|
23
|
-
Spec::Example::
|
23
|
+
Spec::Example::set_location(args, caller(0)[1])
|
24
24
|
Spec::Example::ExampleGroupFactory.assign_scope(self, args)
|
25
25
|
Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
|
26
26
|
end
|
@@ -42,7 +42,7 @@ module Spec
|
|
42
42
|
# end
|
43
43
|
# end
|
44
44
|
def share_examples_for(*args, &block)
|
45
|
-
Spec::Example::
|
45
|
+
Spec::Example::set_location(args, caller(0)[1])
|
46
46
|
Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block)
|
47
47
|
end
|
48
48
|
alias :shared_examples_for :share_examples_for
|
@@ -74,7 +74,7 @@ module Spec
|
|
74
74
|
def share_as(name, &block)
|
75
75
|
begin
|
76
76
|
args = [name]
|
77
|
-
Spec::Example::
|
77
|
+
Spec::Example::set_location(args, caller(0)[1])
|
78
78
|
Object.const_set(name, Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block))
|
79
79
|
rescue NameError => e
|
80
80
|
raise NameError.new(e.message + "\nThe first argument to share_as must be a legal name for a constant\n")
|
data/lib/spec/example.rb
CHANGED
@@ -158,9 +158,9 @@ module Spec
|
|
158
158
|
return scope_from(*args), options
|
159
159
|
end
|
160
160
|
|
161
|
-
def
|
161
|
+
def set_location(args, location) # :nodoc:
|
162
162
|
args << {} unless Hash === args.last
|
163
|
-
args.last[:
|
163
|
+
args.last[:location] ||= location
|
164
164
|
end
|
165
165
|
|
166
166
|
private
|
@@ -174,7 +174,8 @@ end
|
|
174
174
|
|
175
175
|
require 'timeout'
|
176
176
|
require 'spec/example/predicate_matchers'
|
177
|
-
require 'spec/example/
|
177
|
+
require 'spec/example/example_group_proxy'
|
178
|
+
require 'spec/example/example_proxy'
|
178
179
|
require 'spec/example/subject'
|
179
180
|
require 'spec/example/before_and_after_hooks'
|
180
181
|
require 'spec/example/pending'
|
@@ -19,14 +19,12 @@ module Spec
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def create_shared_example_group(*args, &example_group_block) # :nodoc:
|
22
|
-
::Spec::Example::add_spec_path_to(args)
|
23
22
|
::Spec::Example::SharedExampleGroup.register(*args, &example_group_block)
|
24
23
|
end
|
25
24
|
|
26
25
|
def create_example_group(*args, &block)
|
27
26
|
raise ArgumentError if args.empty?
|
28
27
|
raise ArgumentError unless block
|
29
|
-
Spec::Example::add_spec_path_to(args)
|
30
28
|
superclass = determine_superclass(args.last)
|
31
29
|
superclass.describe(*args, &block)
|
32
30
|
end
|
@@ -71,7 +69,7 @@ module Spec
|
|
71
69
|
def determine_superclass(opts)
|
72
70
|
if type = opts[:type]
|
73
71
|
self[type]
|
74
|
-
elsif opts[:
|
72
|
+
elsif opts[:location] =~ /spec(\\|\/)(#{@example_group_types.keys.sort_by{|k| k.to_s.length}.reverse.join('|')})/
|
75
73
|
self[$2 == '' ? nil : $2.to_sym]
|
76
74
|
else
|
77
75
|
self[nil]
|
@@ -10,7 +10,7 @@ module Spec
|
|
10
10
|
include Spec::Example::Subject::ExampleGroupMethods
|
11
11
|
include Spec::Example::PredicateMatchers
|
12
12
|
|
13
|
-
attr_reader :options, :
|
13
|
+
attr_reader :options, :location
|
14
14
|
|
15
15
|
def inherited(klass) # :nodoc:
|
16
16
|
super
|
@@ -19,7 +19,7 @@ module Spec
|
|
19
19
|
|
20
20
|
# Provides the backtrace up to where this example_group was declared.
|
21
21
|
def backtrace
|
22
|
-
@backtrace
|
22
|
+
defined?(@backtrace) ? @backtrace : nil
|
23
23
|
end
|
24
24
|
|
25
25
|
# Deprecated - use +backtrace()+
|
@@ -47,7 +47,7 @@ WARNING
|
|
47
47
|
#
|
48
48
|
def describe(*args, &example_group_block)
|
49
49
|
if example_group_block
|
50
|
-
Spec::Example::
|
50
|
+
Spec::Example::set_location(args, caller(0)[1])
|
51
51
|
options = args.last
|
52
52
|
if options[:shared]
|
53
53
|
ExampleGroupFactory.create_shared_example_group(*args, &example_group_block)
|
@@ -70,10 +70,10 @@ WARNING
|
|
70
70
|
# Creates an instance of the current example group class and adds it to
|
71
71
|
# a collection of examples of the current example group.
|
72
72
|
def example(description=nil, options={}, backtrace=nil, &implementation)
|
73
|
-
|
74
|
-
|
75
|
-
example_implementations[
|
76
|
-
|
73
|
+
example_proxy = ExampleProxy.new(description, options, backtrace || caller(0)[1])
|
74
|
+
example_proxies << example_proxy
|
75
|
+
example_implementations[example_proxy] = implementation || pending_implementation
|
76
|
+
example_proxy
|
77
77
|
end
|
78
78
|
|
79
79
|
def pending_implementation
|
@@ -108,12 +108,12 @@ WARNING
|
|
108
108
|
def set_description(*args)
|
109
109
|
@description_args, @options = Spec::Example.args_and_options(*args)
|
110
110
|
@backtrace = caller(1)
|
111
|
-
@
|
111
|
+
@location = File.expand_path(options[:location]) if options[:location]
|
112
112
|
self
|
113
113
|
end
|
114
114
|
|
115
115
|
def notify(listener) # :nodoc:
|
116
|
-
listener.add_example_group(self)
|
116
|
+
listener.add_example_group(ExampleGroupProxy.new(self))
|
117
117
|
end
|
118
118
|
|
119
119
|
def description
|
@@ -138,8 +138,8 @@ WARNING
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
def
|
142
|
-
@
|
141
|
+
def example_proxies # :nodoc:
|
142
|
+
@example_proxies ||= []
|
143
143
|
end
|
144
144
|
|
145
145
|
def example_implementations # :nodoc:
|
@@ -147,25 +147,17 @@ WARNING
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def examples(run_options=nil) #:nodoc:
|
150
|
-
(run_options && run_options.reverse) ?
|
150
|
+
(run_options && run_options.reverse) ? example_proxies.reverse : example_proxies
|
151
151
|
end
|
152
152
|
|
153
153
|
def number_of_examples #:nodoc:
|
154
|
-
|
154
|
+
example_proxies.length
|
155
155
|
end
|
156
156
|
|
157
157
|
def example_group_hierarchy
|
158
158
|
@example_group_hierarchy ||= ExampleGroupHierarchy.new(self)
|
159
159
|
end
|
160
160
|
|
161
|
-
def filtered_description(filter)
|
162
|
-
build_description_from(
|
163
|
-
*nested_descriptions.collect do |description|
|
164
|
-
description =~ filter ? $1 : description
|
165
|
-
end
|
166
|
-
)
|
167
|
-
end
|
168
|
-
|
169
161
|
def nested_descriptions
|
170
162
|
example_group_hierarchy.nested_descriptions
|
171
163
|
end
|
@@ -195,12 +187,13 @@ WARNING
|
|
195
187
|
|
196
188
|
def run_before_all(run_options)
|
197
189
|
return [true,{}] if example_group_hierarchy.before_all_parts.empty?
|
198
|
-
|
190
|
+
example_proxy = ExampleProxy.new("before(:all)")
|
191
|
+
before_all = new(example_proxy)
|
199
192
|
begin
|
200
193
|
example_group_hierarchy.run_before_all(before_all)
|
201
194
|
return [true, before_all.instance_variable_hash]
|
202
195
|
rescue Exception => e
|
203
|
-
run_options.reporter.example_failed(
|
196
|
+
run_options.reporter.example_failed(example_proxy, e)
|
204
197
|
return [false, before_all.instance_variable_hash]
|
205
198
|
end
|
206
199
|
end
|
@@ -211,7 +204,7 @@ WARNING
|
|
211
204
|
after_all_instance_variables = instance_variables
|
212
205
|
|
213
206
|
examples.each do |example|
|
214
|
-
example_group_instance = new(example
|
207
|
+
example_group_instance = new(example, &example_implementations[example])
|
215
208
|
success &= example_group_instance.execute(run_options, instance_variables)
|
216
209
|
after_all_instance_variables = example_group_instance.instance_variable_hash
|
217
210
|
end
|
@@ -221,18 +214,19 @@ WARNING
|
|
221
214
|
|
222
215
|
def run_after_all(success, instance_variables, run_options)
|
223
216
|
return success if example_group_hierarchy.after_all_parts.empty?
|
224
|
-
|
217
|
+
example_proxy = ExampleProxy.new("after(:all)")
|
218
|
+
after_all = new(example_proxy)
|
225
219
|
after_all.set_instance_variables_from_hash(instance_variables)
|
226
220
|
example_group_hierarchy.run_after_all(after_all)
|
227
221
|
return success
|
228
222
|
rescue Exception => e
|
229
|
-
run_options.reporter.example_failed(
|
223
|
+
run_options.reporter.example_failed(example_proxy, e)
|
230
224
|
return false
|
231
225
|
end
|
232
226
|
|
233
227
|
def examples_to_run(run_options)
|
234
|
-
return
|
235
|
-
|
228
|
+
return example_proxies unless specified_examples?(run_options)
|
229
|
+
example_proxies.reject do |example|
|
236
230
|
matcher = ExampleGroupMethods.matcher_class.
|
237
231
|
new(description.to_s, example.description)
|
238
232
|
!matcher.matches?(run_options.examples)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Spec
|
2
|
+
module Example
|
3
|
+
# Lightweight representation of an example group. This is the object
|
4
|
+
# that is passed to Spec::Runner::Formatter::BaseFormatter#add_example_group
|
5
|
+
class ExampleGroupProxy
|
6
|
+
|
7
|
+
def initialize(example_group) # :nodoc:
|
8
|
+
@description = example_group.description
|
9
|
+
@nested_descriptions = example_group.nested_descriptions
|
10
|
+
@examples = example_group.example_proxies
|
11
|
+
@location = example_group.location
|
12
|
+
@backtrace = example_group.backtrace
|
13
|
+
end
|
14
|
+
|
15
|
+
# This is the docstring passed to the <tt>describe()</tt> method or any
|
16
|
+
# of its aliases
|
17
|
+
attr_reader :description
|
18
|
+
|
19
|
+
# Used by Spec::Runner::Formatter::NestedTextFormatter to access the
|
20
|
+
# docstrings for each example group in a nested group.
|
21
|
+
attr_reader :nested_descriptions
|
22
|
+
|
23
|
+
# A collection of ExampleGroupProxy instances, one for each example
|
24
|
+
# declared in this group.
|
25
|
+
attr_reader :examples
|
26
|
+
|
27
|
+
# The file and line number at which the represented example group
|
28
|
+
# was declared. This is extracted from <tt>caller</tt>, and is therefore
|
29
|
+
# formatted as an individual line in a backtrace.
|
30
|
+
attr_reader :location
|
31
|
+
|
32
|
+
# Deprecated - use location() instead
|
33
|
+
def backtrace
|
34
|
+
@backtrace
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns the nested_descriptions collection with any descriptions
|
38
|
+
# matching the submitted regexp removed.
|
39
|
+
def filtered_description(regexp)
|
40
|
+
build_description_from(
|
41
|
+
*nested_descriptions.collect do |description|
|
42
|
+
description =~ regexp ? $1 : description
|
43
|
+
end
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def ==(other) # :nodoc:
|
48
|
+
other.description == description
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# FIXME - this is duplicated from ExampleGroupMethods
|
54
|
+
def build_description_from(*args)
|
55
|
+
text = args.inject("") do |description, arg|
|
56
|
+
description << " " unless (description == "" || arg.to_s =~ /^(\s|\.|#)/)
|
57
|
+
description << arg.to_s
|
58
|
+
end
|
59
|
+
text == "" ? nil : text
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|