rspec-core 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.document +1 -1
- data/.yardopts +1 -1
- data/Changelog.md +88 -0
- data/{License.txt → LICENSE.md} +6 -5
- data/README.md +18 -3
- data/lib/rspec/core/bisect/example_minimizer.rb +78 -39
- data/lib/rspec/core/configuration.rb +87 -25
- data/lib/rspec/core/configuration_options.rb +1 -1
- data/lib/rspec/core/example.rb +55 -7
- data/lib/rspec/core/example_group.rb +28 -8
- data/lib/rspec/core/example_status_persister.rb +16 -16
- data/lib/rspec/core/formatters/bisect_progress_formatter.rb +44 -15
- data/lib/rspec/core/formatters/exception_presenter.rb +150 -59
- data/lib/rspec/core/formatters/helpers.rb +1 -1
- data/lib/rspec/core/formatters/html_formatter.rb +3 -3
- data/lib/rspec/core/formatters/html_printer.rb +2 -3
- data/lib/rspec/core/formatters/html_snippet_extractor.rb +116 -0
- data/lib/rspec/core/formatters/protocol.rb +9 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +124 -97
- data/lib/rspec/core/formatters.rb +2 -1
- data/lib/rspec/core/hooks.rb +2 -2
- data/lib/rspec/core/memoized_helpers.rb +2 -2
- data/lib/rspec/core/metadata.rb +3 -2
- data/lib/rspec/core/metadata_filter.rb +11 -6
- data/lib/rspec/core/notifications.rb +3 -2
- data/lib/rspec/core/option_parser.rb +22 -4
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +2 -2
- data/lib/rspec/core/rake_task.rb +12 -3
- data/lib/rspec/core/reporter.rb +18 -2
- data/lib/rspec/core/ruby_project.rb +1 -1
- data/lib/rspec/core/shared_example_group.rb +2 -0
- data/lib/rspec/core/source/location.rb +13 -0
- data/lib/rspec/core/source/node.rb +93 -0
- data/lib/rspec/core/source/syntax_highlighter.rb +71 -0
- data/lib/rspec/core/source/token.rb +43 -0
- data/lib/rspec/core/source.rb +76 -0
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +25 -6
- data.tar.gz.sig +0 -0
- metadata +14 -11
- metadata.gz.sig +0 -0
- data/lib/rspec/core/bisect/subset_enumerator.rb +0 -39
- data/lib/rspec/core/mutex.rb +0 -63
- data/lib/rspec/core/reentrant_mutex.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f967099cbbb51b6251a6fb9bcf05ba70638552eb
|
4
|
+
data.tar.gz: d39f0206c2d7d854b9ccf9b6dc445c58ba2b8f73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7053ad7cca8b00f3b74978fd56843ec81669645caf546c0088aab80a5e047383e1be46e688a7882bee80f4de421d9fee78c6c82ce608e1b3abd77b02aa8cf0f4
|
7
|
+
data.tar.gz: e17b394645c54f8ee66e43620d8aedca1284732ca9f30c5a4de91dc9f17f0c0bb992f1f9c2ce01e825d04baf60f59cf7a6a997983e79aae452df1517d4bdcd49
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.document
CHANGED
data/.yardopts
CHANGED
data/Changelog.md
CHANGED
@@ -1,3 +1,91 @@
|
|
1
|
+
### 3.4.0 / 2015-11-11
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.3.2...v3.4.0)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
|
6
|
+
* Combine multiple `--pattern` arguments making them equivalent to
|
7
|
+
`--pattern=1,2,...,n`. (Jon Rowe, #2002)
|
8
|
+
* Improve `inspect` and `to_s` output for `RSpec::Core::Example`
|
9
|
+
objects, replacing Ruby's excessively verbose output. (Gavin Miller, #1922)
|
10
|
+
* Add `silence_filter_announcements` configuration option.
|
11
|
+
(David Raffensperger, #2007)
|
12
|
+
* Add optional `example_finished` notification to the reporter protocol for
|
13
|
+
when you don't care about the example outcome. (Jon Rowe, #2013)
|
14
|
+
* Switch `--bisect` to a recursion-based bisection algorithm rather than
|
15
|
+
a permutation-based one. This better handles cases where an example
|
16
|
+
depends upon multiple other examples instead of just one and minimizes
|
17
|
+
the number of runs necessary to determine that an example set cannot be
|
18
|
+
minimized further. (Simon Coffey, #1997)
|
19
|
+
* Allow simple filters (e.g. `:symbol` key only) to be triggered by truthey
|
20
|
+
values. (Tim Mertens, #2035)
|
21
|
+
* Remove unneeded warning about need for `ansicon` on Windows when using
|
22
|
+
RSpec's `--color` option. (Ashley Engelund, #2038)
|
23
|
+
* Add option to configure RSpec to raise errors when issuing warnings.
|
24
|
+
(Jon Rowe, #2052)
|
25
|
+
* Append the root `cause` of a failure or error to the printed failure
|
26
|
+
output when a `cause` is available. (Adam Magan)
|
27
|
+
* Stop rescuing `NoMemoryError`, `SignalExcepetion`, `Interrupt` and
|
28
|
+
`SystemExit`. It is dangerous to interfere with these. (Myron Marston, #2063)
|
29
|
+
* Add `config.project_source_dirs` setting which RSpec uses to determine
|
30
|
+
if a backtrace line comes from your project source or from some
|
31
|
+
external library. It defaults to `spec`, `lib` and `app` but can be
|
32
|
+
configured differently. (Myron Marston, #2088)
|
33
|
+
* Improve failure line detection so that it looks for the failure line
|
34
|
+
in any project source directory instead of just in the spec file.
|
35
|
+
In addition, if no backtrace lines can be found from a project source
|
36
|
+
file, we fall back to displaying the source of the first backtrace
|
37
|
+
line. This should virtually eliminate the "Unable to find matching
|
38
|
+
line from backtrace" messages. (Myron Marston, #2088)
|
39
|
+
* Add support for `:extra_failure_lines` example metadata that will
|
40
|
+
be appended to the failure output. (bootstraponline, #2092).
|
41
|
+
* Add `RSpec::Core::Example#duplicate_with` to produce new examples
|
42
|
+
with cloned metadata. (bootstraponline, #2098)
|
43
|
+
* Add `RSpec::Core::Configuration#on_example_group_definition` to register
|
44
|
+
hooks to be invoked when example groups are created. (bootstraponline, #2094)
|
45
|
+
* Add `add_example` and `remove_example` to `RSpec::Core::ExampleGroup` to
|
46
|
+
allow manipulating an example groups examples. (bootstraponline, #2095)
|
47
|
+
* Display multiline failure source lines in failure output when Ripper is
|
48
|
+
available (MRI >= 1.9.2, and JRuby >= 1.7.5 && < 9.0.0.0.rc1).
|
49
|
+
(Yuji Nakayama, #2083)
|
50
|
+
* Add `max_displayed_failure_line_count` configuration option
|
51
|
+
(defaults to 10). (Yuji Nakayama, #2083)
|
52
|
+
* Enhance `fail_fast` option so it can take a number (e.g. `--fail-fast=3`)
|
53
|
+
to force the run to abort after the specified number of failures.
|
54
|
+
(Jack Scotti, #2065)
|
55
|
+
* Syntax highlight the failure snippets in text formatters when `color`
|
56
|
+
is enabled and the `coderay` gem is installed on a POSIX system.
|
57
|
+
(Myron Marston, #2109)
|
58
|
+
|
59
|
+
Bug Fixes:
|
60
|
+
|
61
|
+
* Lock `example_status_persistence_file` when reading from and writing
|
62
|
+
to it to prevent race conditions when multiple processes try to use
|
63
|
+
it. (Ben Woosley, #2029)
|
64
|
+
* Fix regression in 3.3 that caused spec file names with square brackets in
|
65
|
+
them (such as `1[]_spec.rb`) to not be loaded properly. (Myron Marston, #2041)
|
66
|
+
* Fix output encoding issue caused by ASCII literal on 1.9.3 (Jon Rowe, #2072)
|
67
|
+
* Fix requires in `rspec/core/rake_task.rb` to avoid double requires
|
68
|
+
seen by some users. (Myron Marston, #2101)
|
69
|
+
|
70
|
+
### 3.3.2 / 2015-07-15
|
71
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.3.1...v3.3.2)
|
72
|
+
|
73
|
+
Bug Fixes:
|
74
|
+
|
75
|
+
* Fix formatters to handle exceptions for which `backtrace` returns `nil`.
|
76
|
+
(Myron Marston, #2023)
|
77
|
+
* Fix duplicate formatter detection so that it allows subclasses of formatters
|
78
|
+
to be added. (Sebastián Tello, #2019)
|
79
|
+
|
80
|
+
### 3.3.1 / 2015-06-18
|
81
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.3.0...v3.3.1)
|
82
|
+
|
83
|
+
Bug Fixes:
|
84
|
+
|
85
|
+
* Correctly run `before(:suite)` (and friends) in the context of an example
|
86
|
+
group instance, thus making the expected RSpec environment available.
|
87
|
+
(Jon Rowe, #1986)
|
88
|
+
|
1
89
|
### 3.3.0 / 2015-06-12
|
2
90
|
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.2.3...v3.3.0)
|
3
91
|
|
data/{License.txt → LICENSE.md}
RENAMED
@@ -1,9 +1,10 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
|
+
=====================
|
2
3
|
|
3
|
-
Copyright
|
4
|
-
Copyright
|
5
|
-
Copyright
|
6
|
-
Copyright
|
4
|
+
* Copyright © 2012 Chad Humphries, David Chelimsky, Myron Marston
|
5
|
+
* Copyright © 2009 Chad Humphries, David Chelimsky
|
6
|
+
* Copyright © 2006 David Chelimsky, The RSpec Development Team
|
7
|
+
* Copyright © 2005 Steven Baker
|
7
8
|
|
8
9
|
Permission is hereby granted, free of charge, to any person obtaining
|
9
10
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -19,6 +19,20 @@ RSpec repos as well. Add the following to your `Gemfile`:
|
|
19
19
|
end
|
20
20
|
```
|
21
21
|
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
Once you've set up the environment, you'll need to cd into the working
|
25
|
+
directory of whichever repo you want to work in. From there you can run the
|
26
|
+
specs and cucumber features, and make patches.
|
27
|
+
|
28
|
+
NOTE: You do not need to use rspec-dev to work on a specific RSpec repo. You
|
29
|
+
can treat each RSpec repo as an independent project.
|
30
|
+
|
31
|
+
* [Build details](BUILD_DETAIL.md)
|
32
|
+
* [Code of Conduct](CODE_OF_CONDUCT.md)
|
33
|
+
* [Detailed contributing guide](CONTRIBUTING.md)
|
34
|
+
* [Development setup guide](DEVELOPMENT.md)
|
35
|
+
|
22
36
|
## Basic Structure
|
23
37
|
|
24
38
|
RSpec uses the words "describe" and "it" so we can express concepts like a conversation:
|
@@ -364,6 +378,7 @@ Finished in 0.000379 seconds
|
|
364
378
|
|
365
379
|
## Also see
|
366
380
|
|
367
|
-
* [
|
368
|
-
* [
|
369
|
-
* [
|
381
|
+
* [https://github.com/rspec/rspec](https://github.com/rspec/rspec)
|
382
|
+
* [https://github.com/rspec/rspec-expectations](https://github.com/rspec/rspec-expectations)
|
383
|
+
* [https://github.com/rspec/rspec-mocks](https://github.com/rspec/rspec-mocks)
|
384
|
+
* [https://github.com/rspec/rspec-rails](https://github.com/rspec/rspec-rails)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
RSpec::Support.require_rspec_core "bisect/subset_enumerator"
|
2
|
-
|
3
1
|
module RSpec
|
4
2
|
module Core
|
5
3
|
module Bisect
|
@@ -18,20 +16,65 @@ module RSpec
|
|
18
16
|
def find_minimal_repro
|
19
17
|
prep
|
20
18
|
|
21
|
-
|
19
|
+
_, duration = track_duration do
|
20
|
+
bisect(non_failing_example_ids)
|
21
|
+
end
|
22
|
+
|
23
|
+
notify(:bisect_complete, :duration => duration,
|
24
|
+
:original_non_failing_count => non_failing_example_ids.size,
|
25
|
+
:remaining_count => remaining_ids.size)
|
26
|
+
|
27
|
+
remaining_ids + failed_example_ids
|
28
|
+
end
|
29
|
+
|
30
|
+
def bisect(candidate_ids)
|
31
|
+
notify(:bisect_dependency_check_started)
|
32
|
+
if get_expected_failures_for?([])
|
33
|
+
notify(:bisect_dependency_check_failed)
|
34
|
+
self.remaining_ids = []
|
35
|
+
return
|
36
|
+
end
|
37
|
+
notify(:bisect_dependency_check_passed)
|
38
|
+
|
39
|
+
bisect_over(candidate_ids)
|
40
|
+
end
|
41
|
+
|
42
|
+
def bisect_over(candidate_ids)
|
43
|
+
return if candidate_ids.one?
|
44
|
+
|
45
|
+
notify(
|
46
|
+
:bisect_round_started,
|
47
|
+
:candidate_range => example_range(candidate_ids),
|
48
|
+
:candidates_count => candidate_ids.size
|
49
|
+
)
|
22
50
|
|
23
|
-
|
24
|
-
|
51
|
+
slice_size = (candidate_ids.length / 2.0).ceil
|
52
|
+
lhs, rhs = candidate_ids.each_slice(slice_size).to_a
|
53
|
+
|
54
|
+
ids_to_ignore, duration = track_duration do
|
55
|
+
[lhs, rhs].find do |ids|
|
25
56
|
get_expected_failures_for?(remaining_ids - ids)
|
26
57
|
end
|
58
|
+
end
|
27
59
|
|
28
|
-
|
29
|
-
|
60
|
+
if ids_to_ignore
|
30
61
|
self.remaining_ids -= ids_to_ignore
|
31
|
-
notify(
|
62
|
+
notify(
|
63
|
+
:bisect_round_ignoring_ids,
|
64
|
+
:ids_to_ignore => ids_to_ignore,
|
65
|
+
:ignore_range => example_range(ids_to_ignore),
|
66
|
+
:remaining_ids => remaining_ids,
|
67
|
+
:duration => duration
|
68
|
+
)
|
69
|
+
bisect_over(candidate_ids - ids_to_ignore)
|
70
|
+
else
|
71
|
+
notify(
|
72
|
+
:bisect_round_detected_multiple_culprits,
|
73
|
+
:duration => duration
|
74
|
+
)
|
75
|
+
bisect_over(lhs)
|
76
|
+
bisect_over(rhs)
|
32
77
|
end
|
33
|
-
|
34
|
-
currently_needed_ids
|
35
78
|
end
|
36
79
|
|
37
80
|
def currently_needed_ids
|
@@ -43,8 +86,27 @@ module RSpec
|
|
43
86
|
"(Not yet enough information to provide any repro command)"
|
44
87
|
end
|
45
88
|
|
89
|
+
# @private
|
90
|
+
# Convenience class for describing a subset of the candidate examples
|
91
|
+
ExampleRange = Struct.new(:start, :finish) do
|
92
|
+
def description
|
93
|
+
if start == finish
|
94
|
+
"example #{start}"
|
95
|
+
else
|
96
|
+
"examples #{start}-#{finish}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
46
101
|
private
|
47
102
|
|
103
|
+
def example_range(ids)
|
104
|
+
ExampleRange.new(
|
105
|
+
non_failing_example_ids.find_index(ids.first) + 1,
|
106
|
+
non_failing_example_ids.find_index(ids.last) + 1
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
48
110
|
def prep
|
49
111
|
notify(:bisect_starting, :original_cli_args => runner.original_cli_args)
|
50
112
|
|
@@ -52,6 +114,7 @@ module RSpec
|
|
52
114
|
original_results = runner.original_results
|
53
115
|
@all_example_ids = original_results.all_example_ids
|
54
116
|
@failed_example_ids = original_results.failed_example_ids
|
117
|
+
@remaining_ids = non_failing_example_ids
|
55
118
|
end
|
56
119
|
|
57
120
|
if @failed_example_ids.empty?
|
@@ -70,7 +133,11 @@ module RSpec
|
|
70
133
|
|
71
134
|
def get_expected_failures_for?(ids)
|
72
135
|
ids_to_run = ids + failed_example_ids
|
73
|
-
notify(
|
136
|
+
notify(
|
137
|
+
:bisect_individual_run_start,
|
138
|
+
:command => runner.repro_command_from(ids_to_run),
|
139
|
+
:ids_to_run => ids_to_run
|
140
|
+
)
|
74
141
|
|
75
142
|
results, duration = track_duration { runner.run(ids_to_run) }
|
76
143
|
notify(:bisect_individual_run_complete, :duration => duration, :results => results)
|
@@ -79,34 +146,6 @@ module RSpec
|
|
79
146
|
(failed_example_ids & results.failed_example_ids) == failed_example_ids
|
80
147
|
end
|
81
148
|
|
82
|
-
INFINITY = (1.0 / 0) # 1.8.7 doesn't define Float::INFINITY so we define our own...
|
83
|
-
|
84
|
-
def each_bisect_round(&block)
|
85
|
-
last_round, duration = track_duration do
|
86
|
-
1.upto(INFINITY) do |round|
|
87
|
-
break if :done == bisect_round(round, &block)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
notify(:bisect_complete, :round => last_round, :duration => duration,
|
92
|
-
:original_non_failing_count => non_failing_example_ids.size,
|
93
|
-
:remaining_count => remaining_ids.size)
|
94
|
-
end
|
95
|
-
|
96
|
-
def bisect_round(round)
|
97
|
-
value, duration = track_duration do
|
98
|
-
subsets = SubsetEnumerator.new(remaining_ids)
|
99
|
-
notify(:bisect_round_started, :round => round,
|
100
|
-
:subset_size => subsets.subset_size,
|
101
|
-
:remaining_count => remaining_ids.size)
|
102
|
-
|
103
|
-
yield subsets
|
104
|
-
end
|
105
|
-
|
106
|
-
notify(:bisect_round_finished, :duration => duration, :round => round)
|
107
|
-
value
|
108
|
-
end
|
109
|
-
|
110
149
|
def track_duration
|
111
150
|
start = ::RSpec::Core::Time.now
|
112
151
|
[yield, ::RSpec::Core::Time.now - start]
|
@@ -4,7 +4,7 @@ RSpec::Support.require_rspec_core "formatters/deprecation_formatter"
|
|
4
4
|
|
5
5
|
module RSpec
|
6
6
|
module Core
|
7
|
-
# rubocop:disable
|
7
|
+
# rubocop:disable Metrics/ClassLength
|
8
8
|
|
9
9
|
# Stores runtime configuration information.
|
10
10
|
#
|
@@ -100,7 +100,11 @@ module RSpec
|
|
100
100
|
#
|
101
101
|
# @note Other scripts invoking `rspec` indirectly will ignore this
|
102
102
|
# setting.
|
103
|
-
|
103
|
+
add_read_only_setting :default_path
|
104
|
+
def default_path=(path)
|
105
|
+
project_source_dirs << path
|
106
|
+
@default_path = path
|
107
|
+
end
|
104
108
|
|
105
109
|
# @macro add_setting
|
106
110
|
# Run examples over DRb (default: `false`). RSpec doesn't supply the DRb
|
@@ -182,7 +186,8 @@ module RSpec
|
|
182
186
|
end
|
183
187
|
|
184
188
|
# @macro add_setting
|
185
|
-
#
|
189
|
+
# If specified, indicates the number of failures required before cleaning
|
190
|
+
# up and exit (default: `nil`).
|
186
191
|
add_setting :fail_fast
|
187
192
|
|
188
193
|
# @macro add_setting
|
@@ -241,6 +246,16 @@ module RSpec
|
|
241
246
|
update_pattern_attr :exclude_pattern, value
|
242
247
|
end
|
243
248
|
|
249
|
+
# @macro add_setting
|
250
|
+
# Specifies which directories contain the source code for your project.
|
251
|
+
# When a failure occurs, RSpec looks through the backtrace to find a
|
252
|
+
# a line of source to print. It first looks for a line coming from
|
253
|
+
# one of the project source directories so that, for example, it prints
|
254
|
+
# the expectation or assertion call rather than the source code from
|
255
|
+
# the expectation or assertion framework.
|
256
|
+
# @return [Array<String>]
|
257
|
+
add_setting :project_source_dirs
|
258
|
+
|
244
259
|
# @macro add_setting
|
245
260
|
# Report the times for the slowest examples (default: `false`).
|
246
261
|
# Use this to specify the number of examples to include in the profile.
|
@@ -293,6 +308,11 @@ module RSpec
|
|
293
308
|
# :cyan]`
|
294
309
|
add_setting :detail_color
|
295
310
|
|
311
|
+
# @macro add_setting
|
312
|
+
# Don't print filter info i.e. "Run options: include {:focus=>true}"
|
313
|
+
# (default `false`).
|
314
|
+
add_setting :silence_filter_announcements
|
315
|
+
|
296
316
|
# Deprecated. This config option was added in RSpec 2 to pave the way
|
297
317
|
# for this being the default behavior in RSpec 3. Now this option is
|
298
318
|
# a no-op.
|
@@ -313,6 +333,11 @@ module RSpec
|
|
313
333
|
# Currently this will place a mutex around memoized values such as let blocks.
|
314
334
|
add_setting :threadsafe
|
315
335
|
|
336
|
+
# @macro add_setting
|
337
|
+
# Maximum count of failed source lines to display in the failure reports.
|
338
|
+
# (default `10`).
|
339
|
+
add_setting :max_displayed_failure_line_count
|
340
|
+
|
316
341
|
# @private
|
317
342
|
add_setting :tty
|
318
343
|
# @private
|
@@ -348,6 +373,7 @@ module RSpec
|
|
348
373
|
@backtrace_formatter = BacktraceFormatter.new
|
349
374
|
|
350
375
|
@default_path = 'spec'
|
376
|
+
@project_source_dirs = %w[ spec lib app ]
|
351
377
|
@deprecation_stream = $stderr
|
352
378
|
@output_stream = $stdout
|
353
379
|
@reporter = nil
|
@@ -367,6 +393,7 @@ module RSpec
|
|
367
393
|
@libs = []
|
368
394
|
@derived_metadata_blocks = FilterableItemRepository::QueryOptimized.new(:any?)
|
369
395
|
@threadsafe = true
|
396
|
+
@max_displayed_failure_line_count = 10
|
370
397
|
|
371
398
|
define_built_in_hooks
|
372
399
|
end
|
@@ -575,7 +602,7 @@ module RSpec
|
|
575
602
|
end
|
576
603
|
|
577
604
|
new_name, old_name = [framework_module, @mock_framework].map do |mod|
|
578
|
-
mod.respond_to?(:framework_name) ?
|
605
|
+
mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed
|
579
606
|
end
|
580
607
|
|
581
608
|
unless new_name == old_name
|
@@ -703,19 +730,7 @@ module RSpec
|
|
703
730
|
end
|
704
731
|
|
705
732
|
# Toggle output color.
|
706
|
-
|
707
|
-
def color=(true_or_false)
|
708
|
-
return unless true_or_false
|
709
|
-
|
710
|
-
if RSpec::Support::OS.windows? && !ENV['ANSICON']
|
711
|
-
RSpec.warning "You must use ANSICON 1.31 or later " \
|
712
|
-
"(http://adoxa.3eeweb.com/ansicon/) to use colour " \
|
713
|
-
"on Windows"
|
714
|
-
@color = false
|
715
|
-
else
|
716
|
-
@color = true
|
717
|
-
end
|
718
|
-
end
|
733
|
+
attr_writer :color
|
719
734
|
|
720
735
|
# @private
|
721
736
|
def libs=(libs)
|
@@ -881,7 +896,7 @@ module RSpec
|
|
881
896
|
# @private
|
882
897
|
def spec_files_with_failures
|
883
898
|
@spec_files_with_failures ||= last_run_statuses.inject(Set.new) do |files, (id, status)|
|
884
|
-
files <<
|
899
|
+
files << Example.parse_id(id).first if status == FAILED_STATUS
|
885
900
|
files
|
886
901
|
end.to_a
|
887
902
|
end
|
@@ -1281,6 +1296,15 @@ module RSpec
|
|
1281
1296
|
@requires += paths
|
1282
1297
|
end
|
1283
1298
|
|
1299
|
+
# @private
|
1300
|
+
def in_project_source_dir_regex
|
1301
|
+
regexes = project_source_dirs.map do |dir|
|
1302
|
+
/\A#{Regexp.escape(File.expand_path(dir))}\//
|
1303
|
+
end
|
1304
|
+
|
1305
|
+
Regexp.union(regexes)
|
1306
|
+
end
|
1307
|
+
|
1284
1308
|
# @private
|
1285
1309
|
if RUBY_VERSION.to_f >= 1.9
|
1286
1310
|
# @private
|
@@ -1322,6 +1346,16 @@ module RSpec
|
|
1322
1346
|
|
1323
1347
|
# @private
|
1324
1348
|
def load_spec_files
|
1349
|
+
# Note which spec files world is already aware of.
|
1350
|
+
# This is generally only needed for when the user runs
|
1351
|
+
# `ruby path/to/spec.rb` (and loads `rspec/autorun`) --
|
1352
|
+
# in that case, the spec file was loaded by `ruby` and
|
1353
|
+
# isn't loaded by us here so we only know about it because
|
1354
|
+
# of an example group being registered in it.
|
1355
|
+
RSpec.world.registered_example_group_files.each do |f|
|
1356
|
+
loaded_spec_files << f # the registered files are already expended absolute paths
|
1357
|
+
end
|
1358
|
+
|
1325
1359
|
files_to_run.uniq.each do |f|
|
1326
1360
|
file = File.expand_path(f)
|
1327
1361
|
load file
|
@@ -1428,6 +1462,25 @@ module RSpec
|
|
1428
1462
|
$VERBOSE
|
1429
1463
|
end
|
1430
1464
|
|
1465
|
+
# @private
|
1466
|
+
RAISE_ERROR_WARNING_NOTIFIER = lambda { |message| raise message }
|
1467
|
+
|
1468
|
+
# Turns warnings into errors. This can be useful when
|
1469
|
+
# you want RSpec to run in a 'strict' no warning situation.
|
1470
|
+
#
|
1471
|
+
# @example
|
1472
|
+
#
|
1473
|
+
# RSpec.configure do |rspec|
|
1474
|
+
# rspec.raise_on_warning = true
|
1475
|
+
# end
|
1476
|
+
def raise_on_warning=(value)
|
1477
|
+
if value
|
1478
|
+
RSpec::Support.warning_notifier = RAISE_ERROR_WARNING_NOTIFIER
|
1479
|
+
else
|
1480
|
+
RSpec::Support.warning_notifier = RSpec::Support::DEFAULT_WARNING_NOTIFIER
|
1481
|
+
end
|
1482
|
+
end
|
1483
|
+
|
1431
1484
|
# Exposes the current running example via the named
|
1432
1485
|
# helper method. RSpec 2.x exposed this via `example`,
|
1433
1486
|
# but in RSpec 3.0, the example is instead exposed via
|
@@ -1638,6 +1691,17 @@ module RSpec
|
|
1638
1691
|
@hooks ||= HookCollections.new(self, FilterableItemRepository::QueryOptimized)
|
1639
1692
|
end
|
1640
1693
|
|
1694
|
+
# Invokes block before defining an example group
|
1695
|
+
def on_example_group_definition(&block)
|
1696
|
+
on_example_group_definition_callbacks << block
|
1697
|
+
end
|
1698
|
+
|
1699
|
+
# @api private
|
1700
|
+
# Returns an array of blocks to call before defining an example group
|
1701
|
+
def on_example_group_definition_callbacks
|
1702
|
+
@on_example_group_definition_callbacks ||= []
|
1703
|
+
end
|
1704
|
+
|
1641
1705
|
private
|
1642
1706
|
|
1643
1707
|
def handle_suite_hook(args, collection, append_or_prepend, hook_type, block)
|
@@ -1714,18 +1778,16 @@ module RSpec
|
|
1714
1778
|
end
|
1715
1779
|
end
|
1716
1780
|
|
1717
|
-
# @private
|
1718
|
-
ON_SQUARE_BRACKETS = /[\[\]]/
|
1719
|
-
|
1720
1781
|
def extract_location(path)
|
1721
1782
|
match = /^(.*?)((?:\:\d+)+)$/.match(path)
|
1722
1783
|
|
1723
1784
|
if match
|
1724
1785
|
captures = match.captures
|
1725
|
-
path
|
1786
|
+
path = captures[0]
|
1787
|
+
lines = captures[1][1..-1].split(":").map(&:to_i)
|
1726
1788
|
filter_manager.add_location path, lines
|
1727
1789
|
else
|
1728
|
-
path, scoped_ids =
|
1790
|
+
path, scoped_ids = Example.parse_id(path)
|
1729
1791
|
filter_manager.add_ids(path, scoped_ids.split(/\s*,\s*/)) if scoped_ids
|
1730
1792
|
end
|
1731
1793
|
|
@@ -1745,7 +1807,7 @@ module RSpec
|
|
1745
1807
|
around(:example, :aggregate_failures => true) do |procsy|
|
1746
1808
|
begin
|
1747
1809
|
aggregate_failures(nil, :hide_backtrace => true, &procsy)
|
1748
|
-
rescue
|
1810
|
+
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => exception
|
1749
1811
|
procsy.example.set_aggregate_failures_exception(exception)
|
1750
1812
|
end
|
1751
1813
|
end
|
@@ -1802,6 +1864,6 @@ module RSpec
|
|
1802
1864
|
@spec_files_with_failures = nil
|
1803
1865
|
end
|
1804
1866
|
end
|
1805
|
-
# rubocop:enable
|
1867
|
+
# rubocop:enable Metrics/ClassLength
|
1806
1868
|
end
|
1807
1869
|
end
|