rspec-core 3.0.4 → 3.1.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.tar.gz.sig +0 -0
- data/Changelog.md +67 -0
- data/lib/rspec/core.rb +3 -1
- data/lib/rspec/core/backtrace_formatter.rb +13 -10
- data/lib/rspec/core/configuration.rb +123 -57
- data/lib/rspec/core/configuration_options.rb +12 -12
- data/lib/rspec/core/drb.rb +11 -11
- data/lib/rspec/core/dsl.rb +0 -1
- data/lib/rspec/core/example.rb +39 -12
- data/lib/rspec/core/example_group.rb +31 -98
- data/lib/rspec/core/filter_manager.rb +16 -17
- data/lib/rspec/core/formatters.rb +14 -13
- data/lib/rspec/core/formatters/base_formatter.rb +8 -113
- data/lib/rspec/core/formatters/base_text_formatter.rb +3 -5
- data/lib/rspec/core/formatters/console_codes.rb +1 -2
- data/lib/rspec/core/formatters/deprecation_formatter.rb +2 -3
- data/lib/rspec/core/formatters/documentation_formatter.rb +3 -4
- data/lib/rspec/core/formatters/helpers.rb +5 -6
- data/lib/rspec/core/formatters/html_formatter.rb +20 -19
- data/lib/rspec/core/formatters/html_printer.rb +6 -5
- data/lib/rspec/core/formatters/json_formatter.rb +3 -2
- data/lib/rspec/core/formatters/profile_formatter.rb +0 -2
- data/lib/rspec/core/formatters/progress_formatter.rb +4 -4
- data/lib/rspec/core/formatters/protocol.rb +163 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +7 -6
- data/lib/rspec/core/hooks.rb +25 -10
- data/lib/rspec/core/memoized_helpers.rb +7 -5
- data/lib/rspec/core/metadata.rb +29 -30
- data/lib/rspec/core/metadata_filter.rb +66 -66
- data/lib/rspec/core/minitest_assertions_adapter.rb +1 -1
- data/lib/rspec/core/mocking_adapters/flexmock.rb +3 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +3 -1
- data/lib/rspec/core/mocking_adapters/null.rb +2 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +3 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +3 -1
- data/lib/rspec/core/notifications.rb +36 -29
- data/lib/rspec/core/option_parser.rb +29 -25
- data/lib/rspec/core/ordering.rb +8 -9
- data/lib/rspec/core/pending.rb +6 -8
- data/lib/rspec/core/project_initializer.rb +4 -2
- data/lib/rspec/core/project_initializer/.rspec +0 -1
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +37 -26
- data/lib/rspec/core/rake_task.rb +37 -19
- data/lib/rspec/core/reporter.rb +13 -16
- data/lib/rspec/core/ruby_project.rb +2 -2
- data/lib/rspec/core/runner.rb +11 -14
- data/lib/rspec/core/shared_example_group.rb +14 -13
- data/lib/rspec/core/test_unit_assertions_adapter.rb +1 -1
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/warnings.rb +4 -4
- data/lib/rspec/core/world.rb +22 -24
- metadata +6 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee058acded3da2b270f4643a7cbf909f86a708ce
|
4
|
+
data.tar.gz: 88eaf5e071b90d31c28ce0d9ec9f92722a25bc88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ce2c03aa04796bc5fd6414bd84ebde8b80ba3f0e7ec379b00fdb1fc53210c953b6758ee618e16b6969658a15536c217cc02b952263215df4a398d85b128e789
|
7
|
+
data.tar.gz: 7c554927f21c2eb43b24b423950ffeb0c7239943f3871be8b2f86cb5beb433693bfa252f97ac7fc574246f8e97f10e3064a13658a6ec2acb20933d2b13bd2f70
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,3 +1,62 @@
|
|
1
|
+
### 3.1.0 / 2014-09-04
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.4...v3.1.0)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
|
6
|
+
* Update files generated by `rspec --init` so that warnings are enabled
|
7
|
+
in commented out section of `spec_helper` rather than `.rspec` so users
|
8
|
+
have to consciously opt-in to the setting. (Andrew Hooker, #1572)
|
9
|
+
* Update `spec_helper` generated by `rspec --init` so that it sets the new
|
10
|
+
rspec-expectations `include_chain_clauses_in_custom_matcher_descriptions`
|
11
|
+
config option (which will be on by default in RSpec 4) and also sets the
|
12
|
+
rspec-mocks `verify_partial_doubles` option (which will also default
|
13
|
+
to on in RSpec 4). (Myron Marston, #1647)
|
14
|
+
* Provide an `inspect` output for example procsy objects (used in around
|
15
|
+
hooks) that doesn't make them look like procs. (Jon Rowe, #1620)
|
16
|
+
* Remove a few unneeded `require` statements from
|
17
|
+
`rspec/core/rake_task.rb`, making it even more lighterweight.
|
18
|
+
(Myron Marston, #1640)
|
19
|
+
* Allow rspec-core to be used when neither rspec-mocks or
|
20
|
+
rspec-expectations are installed, without requiring any
|
21
|
+
user configuration. (Sam Phippen, Myron Marston, #1615)
|
22
|
+
* Don't filter out gems from backtraces by default. (The RSpec
|
23
|
+
gems will still be filtered). User feedback has indicated
|
24
|
+
that including gems in default backtraces will be useful.
|
25
|
+
(Myron Marston, #1641)
|
26
|
+
* Add new `config.filter_gems_from_backtrace "rack", "rake"` API
|
27
|
+
to easily filter the named gems from backtraces. (Myron Marston, #1682)
|
28
|
+
* Fix default backtrace filters so that the RSpec binary is
|
29
|
+
excluded when installing RSpec as a bundler `:git` dependency.
|
30
|
+
(Myron Marston, #1648)
|
31
|
+
* Simplify command generated by the rake task so that it no longer
|
32
|
+
includes unnecessary `-S`. (Myron Marston, #1559)
|
33
|
+
* Add `--exclude-pattern` CLI option, `config.exclude_pattern =` config
|
34
|
+
option and `task.exclude_pattern =` rake task config option. Matching
|
35
|
+
files will be excluded. (John Gesimondo, Myron Marston, #1651, #1671)
|
36
|
+
* When an around hook fails to execute the example, mark it as
|
37
|
+
pending (rather than passing) so the user is made aware of the
|
38
|
+
fact that the example did not actually run. (Myron Marston, #1660)
|
39
|
+
* Remove dependency on `FileUtils` from the standard library so that users do
|
40
|
+
not get false positives where their code relies on it but they are not
|
41
|
+
requiring it. (Sam Phippen, #1565)
|
42
|
+
|
43
|
+
Bug Fixes:
|
44
|
+
|
45
|
+
* Fix rake task `t.pattern =` option so that it does not run all specs
|
46
|
+
when it matches no files, by passing along a `--pattern` option to
|
47
|
+
the `rspec` command, rather than resolving the file list and passing
|
48
|
+
along the files individually. (Evgeny Zislis, #1653)
|
49
|
+
* Fix rake task default pattern so that it follows symlinks properly.
|
50
|
+
(Myron Marston, #1672)
|
51
|
+
* Fix default pattern used with `rspec` command so that it follows
|
52
|
+
symlinks properly. (Myron Marston, #1672)
|
53
|
+
* Change how we assign constant names to example group classes so that
|
54
|
+
it avoids a problem with `describe "Core"`. (Daniela Wellisz, #1679)
|
55
|
+
* Handle rendering exceptions that have a different encoding than that
|
56
|
+
of their original source file. (Jon Rowe, #1681)
|
57
|
+
* Allow access to message_lines without colour for failed examples even
|
58
|
+
when they're part of a shared example group. (tomykaira, #1689)
|
59
|
+
|
1
60
|
### 3.0.4 / 2014-08-14
|
2
61
|
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.0.3...v3.0.4)
|
3
62
|
|
@@ -385,6 +444,14 @@ Deprecations:
|
|
385
444
|
longer has an affect now that the behavior it enabled is always
|
386
445
|
enabled. (Myron Marston)
|
387
446
|
|
447
|
+
### 2.99.2 / 2014-08-19
|
448
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.1...v2.99.2)
|
449
|
+
|
450
|
+
Enhancements:
|
451
|
+
|
452
|
+
* Improve deprecation warning for RSpec 3 change in `describe <a symbol>`
|
453
|
+
behavior. (Jon Rowe, #1667)
|
454
|
+
|
388
455
|
### 2.99.1 / 2014-06-19
|
389
456
|
[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.0...v2.99.1)
|
390
457
|
|
data/lib/rspec/core.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
# rubocop:disable Style/GlobalVars
|
1
2
|
$_rspec_core_load_started_at = Time.now
|
3
|
+
# rubocop:enable Style/GlobalVars
|
4
|
+
|
2
5
|
require 'rbconfig'
|
3
6
|
|
4
7
|
require "rspec/support"
|
@@ -64,7 +67,6 @@ module RSpec
|
|
64
67
|
config.expose_dsl_globally = true
|
65
68
|
config
|
66
69
|
end
|
67
|
-
|
68
70
|
end
|
69
71
|
|
70
72
|
# Yields the global configuration to a block.
|
@@ -8,27 +8,30 @@ module RSpec
|
|
8
8
|
def initialize
|
9
9
|
@full_backtrace = false
|
10
10
|
|
11
|
-
patterns = [
|
12
|
-
|
13
|
-
|
14
|
-
"bin/",
|
15
|
-
"/gems/",
|
16
|
-
].map { |s| Regexp.new(s.gsub("/", File::SEPARATOR)) }
|
11
|
+
patterns = %w[ /lib\d*/ruby/ bin/ exe/rspec ]
|
12
|
+
patterns << "org/jruby/" if RUBY_PLATFORM == 'java'
|
13
|
+
patterns.map! { |s| Regexp.new(s.gsub("/", File::SEPARATOR)) }
|
17
14
|
|
18
15
|
@system_exclusion_patterns = [Regexp.union(RSpec::CallerFilter::IGNORE_REGEX, *patterns)]
|
19
16
|
@exclusion_patterns = [] + @system_exclusion_patterns
|
20
17
|
@inclusion_patterns = [Regexp.new(Dir.getwd)]
|
21
18
|
end
|
22
19
|
|
23
|
-
|
24
|
-
@full_backtrace = full_backtrace
|
25
|
-
end
|
20
|
+
attr_writer :full_backtrace
|
26
21
|
|
27
22
|
def full_backtrace?
|
28
23
|
@full_backtrace || @exclusion_patterns.empty?
|
29
24
|
end
|
30
25
|
|
31
|
-
def
|
26
|
+
def filter_gem(gem_name)
|
27
|
+
sep = File::SEPARATOR
|
28
|
+
pattern = /#{sep}#{gem_name}(-[^#{sep}]+)?#{sep}/
|
29
|
+
|
30
|
+
@exclusion_patterns << pattern
|
31
|
+
@system_exclusion_patterns << pattern
|
32
|
+
end
|
33
|
+
|
34
|
+
def format_backtrace(backtrace, options={})
|
32
35
|
return backtrace if options[:full_backtrace]
|
33
36
|
|
34
37
|
backtrace.map { |l| backtrace_line(l) }.compact.
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
1
|
RSpec::Support.require_rspec_core "backtrace_formatter"
|
4
2
|
RSpec::Support.require_rspec_core "ruby_project"
|
5
3
|
RSpec::Support.require_rspec_core "formatters/deprecation_formatter"
|
6
4
|
|
7
5
|
module RSpec
|
8
6
|
module Core
|
7
|
+
# rubocop:disable Style/ClassLength
|
8
|
+
|
9
9
|
# Stores runtime configuration information.
|
10
10
|
#
|
11
11
|
# Configuration options are loaded from `~/.rspec`, `.rspec`,
|
@@ -52,7 +52,7 @@ module RSpec
|
|
52
52
|
|
53
53
|
# @private
|
54
54
|
def self.define_predicate_for(*names)
|
55
|
-
names.each {|name| alias_method "#{name}?", name}
|
55
|
+
names.each { |name| alias_method "#{name}?", name }
|
56
56
|
end
|
57
57
|
|
58
58
|
# @private
|
@@ -60,7 +60,7 @@ module RSpec
|
|
60
60
|
# Invoked by the `add_setting` instance method. Use that method on a
|
61
61
|
# `Configuration` instance rather than this class method.
|
62
62
|
def self.add_setting(name, opts={})
|
63
|
-
raise "Use the instance add_setting method if you want to set a default" if opts.
|
63
|
+
raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
|
64
64
|
attr_writer name
|
65
65
|
add_read_only_setting name
|
66
66
|
|
@@ -73,7 +73,7 @@ module RSpec
|
|
73
73
|
#
|
74
74
|
# As `add_setting` but only add the reader
|
75
75
|
def self.add_read_only_setting(name, opts={})
|
76
|
-
raise "Use the instance add_setting method if you want to set a default" if opts.
|
76
|
+
raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
|
77
77
|
define_reader name
|
78
78
|
define_predicate_for name
|
79
79
|
end
|
@@ -89,6 +89,9 @@ module RSpec
|
|
89
89
|
# Path to use if no path is provided to the `rspec` command (default:
|
90
90
|
# `"spec"`). Allows you to just type `rspec` instead of `rspec spec` to
|
91
91
|
# run all the examples in the `spec` directory.
|
92
|
+
#
|
93
|
+
# Note: Other scripts invoking `rspec` indirectly will ignore this
|
94
|
+
# setting.
|
92
95
|
add_setting :default_path
|
93
96
|
|
94
97
|
# @macro add_setting
|
@@ -133,10 +136,10 @@ module RSpec
|
|
133
136
|
# @param value [IO, String] IO to write to or filename to write to
|
134
137
|
def deprecation_stream=(value)
|
135
138
|
if @reporter && !value.equal?(@deprecation_stream)
|
136
|
-
warn "RSpec's reporter has already been initialized with "
|
137
|
-
"#{deprecation_stream.inspect} as the deprecation stream, so your change to "
|
138
|
-
"`deprecation_stream` will be ignored. You should configure it earlier for "
|
139
|
-
"it to take effect, or use the `--deprecation-out` CLI option. "
|
139
|
+
warn "RSpec's reporter has already been initialized with " \
|
140
|
+
"#{deprecation_stream.inspect} as the deprecation stream, so your change to "\
|
141
|
+
"`deprecation_stream` will be ignored. You should configure it earlier for " \
|
142
|
+
"it to take effect, or use the `--deprecation-out` CLI option. " \
|
140
143
|
"(Called from #{CallerFilter.first_non_rspec_line})"
|
141
144
|
else
|
142
145
|
@deprecation_stream = value
|
@@ -173,9 +176,9 @@ module RSpec
|
|
173
176
|
# @attr value [IO] value for output, defaults to $stdout
|
174
177
|
def output_stream=(value)
|
175
178
|
if @reporter && !value.equal?(@output_stream)
|
176
|
-
warn "RSpec's reporter has already been initialized with "
|
177
|
-
"#{output_stream.inspect} as the output stream, so your change to "
|
178
|
-
"`output_stream` will be ignored. You should configure it earlier for "
|
179
|
+
warn "RSpec's reporter has already been initialized with " \
|
180
|
+
"#{output_stream.inspect} as the output stream, so your change to "\
|
181
|
+
"`output_stream` will be ignored. You should configure it earlier for " \
|
179
182
|
"it to take effect. (Called from #{CallerFilter.first_non_rspec_line})"
|
180
183
|
else
|
181
184
|
@output_stream = value
|
@@ -183,17 +186,23 @@ module RSpec
|
|
183
186
|
end
|
184
187
|
|
185
188
|
# @macro define_reader
|
186
|
-
# Load files matching this pattern (default: `'
|
189
|
+
# Load files matching this pattern (default: `'**{,/*/**}/*_spec.rb'`)
|
187
190
|
define_reader :pattern
|
188
191
|
|
189
192
|
# Set pattern to match files to load
|
190
193
|
# @attr value [String] the filename pattern to filter spec files by
|
191
194
|
def pattern=(value)
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
195
|
+
update_pattern_attr :pattern, value
|
196
|
+
end
|
197
|
+
|
198
|
+
# @macro define_reader
|
199
|
+
# Exclude files matching this pattern
|
200
|
+
define_reader :exclude_pattern
|
201
|
+
|
202
|
+
# Set pattern to match files to exclude
|
203
|
+
# @attr value [String] the filename pattern to exclude spec files by
|
204
|
+
def exclude_pattern=(value)
|
205
|
+
update_pattern_attr :exclude_pattern, value
|
197
206
|
end
|
198
207
|
|
199
208
|
# @macro add_setting
|
@@ -250,9 +259,9 @@ module RSpec
|
|
250
259
|
# Deprecated. This config option was added in RSpec 2 to pave the way
|
251
260
|
# for this being the default behavior in RSpec 3. Now this option is
|
252
261
|
# a no-op.
|
253
|
-
def treat_symbols_as_metadata_keys_with_true_values=(
|
262
|
+
def treat_symbols_as_metadata_keys_with_true_values=(_value)
|
254
263
|
RSpec.deprecate("RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values=",
|
255
|
-
:message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= "
|
264
|
+
:message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= " \
|
256
265
|
"is deprecated, it is now set to true as default and setting it to false has no effect.")
|
257
266
|
end
|
258
267
|
|
@@ -273,13 +282,16 @@ module RSpec
|
|
273
282
|
attr_reader :backtrace_formatter, :ordering_manager
|
274
283
|
|
275
284
|
def initialize
|
285
|
+
# rubocop:disable Style/GlobalVars
|
276
286
|
@start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now
|
287
|
+
# rubocop:enable Style/GlobalVars
|
277
288
|
@expectation_frameworks = []
|
278
289
|
@include_or_extend_modules = []
|
279
290
|
@mock_framework = nil
|
280
291
|
@files_or_directories_to_run = []
|
281
292
|
@color = false
|
282
|
-
@pattern = '
|
293
|
+
@pattern = '**{,/*/**}/*_spec.rb'
|
294
|
+
@exclude_pattern = ''
|
283
295
|
@failure_exit_code = 1
|
284
296
|
@spec_files_loaded = false
|
285
297
|
|
@@ -365,7 +377,13 @@ module RSpec
|
|
365
377
|
|
366
378
|
# Returns the configured mock framework adapter module
|
367
379
|
def mock_framework
|
368
|
-
|
380
|
+
if @mock_framework.nil?
|
381
|
+
begin
|
382
|
+
mock_with :rspec
|
383
|
+
rescue LoadError
|
384
|
+
mock_with :nothing
|
385
|
+
end
|
386
|
+
end
|
369
387
|
@mock_framework
|
370
388
|
end
|
371
389
|
|
@@ -413,6 +431,28 @@ module RSpec
|
|
413
431
|
@backtrace_formatter.inclusion_patterns = patterns
|
414
432
|
end
|
415
433
|
|
434
|
+
# Adds {#backtrace_exclusion_patterns} that will filter lines from
|
435
|
+
# the named gems from backtraces.
|
436
|
+
#
|
437
|
+
# @param gem_names [Array<String>] Names of the gems to filter
|
438
|
+
#
|
439
|
+
# @example
|
440
|
+
# RSpec.configure do |config|
|
441
|
+
# config.filter_gems_from_backtrace "rack", "rake"
|
442
|
+
# end
|
443
|
+
#
|
444
|
+
# @note The patterns this adds will match the named gems in their common
|
445
|
+
# locations (e.g. system gems, vendored with bundler, installed as a
|
446
|
+
# :git dependency with bundler, etc) but is not guaranteed to work for
|
447
|
+
# all possible gem locations. For example, if you have the gem source
|
448
|
+
# in a directory with a completely unrelated name, and use bundler's
|
449
|
+
# :path option, this will not filter it.
|
450
|
+
def filter_gems_from_backtrace(*gem_names)
|
451
|
+
gem_names.each do |name|
|
452
|
+
@backtrace_formatter.filter_gem(name)
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
416
456
|
# @private
|
417
457
|
MOCKING_ADAPTERS = {
|
418
458
|
:rspec => :RSpec,
|
@@ -452,19 +492,20 @@ module RSpec
|
|
452
492
|
# mod_config.custom_setting = true
|
453
493
|
# end
|
454
494
|
def mock_with(framework)
|
455
|
-
framework_module =
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
495
|
+
framework_module =
|
496
|
+
if framework.is_a?(Module)
|
497
|
+
framework
|
498
|
+
else
|
499
|
+
const_name = MOCKING_ADAPTERS.fetch(framework) do
|
500
|
+
raise ArgumentError,
|
501
|
+
"Unknown mocking framework: #{framework.inspect}. " \
|
502
|
+
"Pass a module or one of #{MOCKING_ADAPTERS.keys.inspect}"
|
503
|
+
end
|
504
|
+
|
505
|
+
RSpec::Support.require_rspec_core "mocking_adapters/#{const_name.to_s.downcase}"
|
506
|
+
RSpec::Core::MockingAdapters.const_get(const_name)
|
462
507
|
end
|
463
508
|
|
464
|
-
RSpec::Support.require_rspec_core "mocking_adapters/#{const_name.to_s.downcase}"
|
465
|
-
RSpec::Core::MockingAdapters.const_get(const_name)
|
466
|
-
end
|
467
|
-
|
468
509
|
new_name, old_name = [framework_module, @mock_framework].map do |mod|
|
469
510
|
mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed
|
470
511
|
end
|
@@ -483,7 +524,13 @@ module RSpec
|
|
483
524
|
|
484
525
|
# Returns the configured expectation framework adapter module(s)
|
485
526
|
def expectation_frameworks
|
486
|
-
|
527
|
+
if @expectation_frameworks.empty?
|
528
|
+
begin
|
529
|
+
expect_with :rspec
|
530
|
+
rescue LoadError
|
531
|
+
expect_with Module.new
|
532
|
+
end
|
533
|
+
end
|
487
534
|
@expectation_frameworks
|
488
535
|
end
|
489
536
|
|
@@ -573,20 +620,20 @@ module RSpec
|
|
573
620
|
# @param output [IO] an output stream to use, defaults to the current
|
574
621
|
# `output_stream`
|
575
622
|
# @return [Boolean]
|
576
|
-
def color_enabled?(output
|
623
|
+
def color_enabled?(output=output_stream)
|
577
624
|
output_to_tty?(output) && color
|
578
625
|
end
|
579
626
|
|
580
627
|
# Toggle output color
|
581
628
|
# @attr true_or_false [Boolean] toggle color enabled
|
582
629
|
def color=(true_or_false)
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
630
|
+
return unless true_or_false
|
631
|
+
|
632
|
+
if RSpec.world.windows_os? && !ENV['ANSICON']
|
633
|
+
RSpec.warning "You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use colour on Windows"
|
634
|
+
@color = false
|
635
|
+
else
|
636
|
+
@color = true
|
590
637
|
end
|
591
638
|
end
|
592
639
|
|
@@ -601,7 +648,7 @@ module RSpec
|
|
601
648
|
# Run examples matching on `description` in all files to run.
|
602
649
|
# @param description [String, Regexp] the pattern to filter on
|
603
650
|
def full_description=(description)
|
604
|
-
filter_run :full_description => Regexp.union(*Array(description).map {|d| Regexp.new(d) })
|
651
|
+
filter_run :full_description => Regexp.union(*Array(description).map { |d| Regexp.new(d) })
|
605
652
|
end
|
606
653
|
|
607
654
|
# @return [Array] full description filter
|
@@ -816,7 +863,7 @@ module RSpec
|
|
816
863
|
# specs, but does not add any additional documentation. We use this
|
817
864
|
# in rspec to define `it_should_behave_like` (for backward
|
818
865
|
# compatibility), but we also add docs for that method.
|
819
|
-
def alias_it_behaves_like_to(new_name, report_label
|
866
|
+
def alias_it_behaves_like_to(new_name, report_label='')
|
820
867
|
RSpec::Core::ExampleGroup.define_nested_shared_group_method(new_name, report_label)
|
821
868
|
end
|
822
869
|
alias_method :alias_it_should_behave_like_to, :alias_it_behaves_like_to
|
@@ -1022,7 +1069,7 @@ module RSpec
|
|
1022
1069
|
def requires=(paths)
|
1023
1070
|
directories = ['lib', default_path].select { |p| File.directory? p }
|
1024
1071
|
RSpec::Core::RubyProject.add_to_load_path(*directories)
|
1025
|
-
paths.each {|path| require path}
|
1072
|
+
paths.each { |path| require path }
|
1026
1073
|
@requires += paths
|
1027
1074
|
end
|
1028
1075
|
|
@@ -1055,7 +1102,7 @@ module RSpec
|
|
1055
1102
|
|
1056
1103
|
# @private
|
1057
1104
|
def load_spec_files
|
1058
|
-
files_to_run.uniq.each {|f| load File.expand_path(f) }
|
1105
|
+
files_to_run.uniq.each { |f| load File.expand_path(f) }
|
1059
1106
|
@spec_files_loaded = true
|
1060
1107
|
end
|
1061
1108
|
|
@@ -1283,16 +1330,25 @@ module RSpec
|
|
1283
1330
|
end
|
1284
1331
|
|
1285
1332
|
def gather_directories(path)
|
1333
|
+
include_files = get_matching_files(path, pattern)
|
1334
|
+
exclude_files = get_matching_files(path, exclude_pattern)
|
1335
|
+
(include_files - exclude_files).sort.uniq
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
def get_matching_files(path, pattern)
|
1286
1339
|
stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}"
|
1287
|
-
|
1288
|
-
files.sort
|
1340
|
+
pattern =~ /^#{Regexp.escape path}/ ? Dir[stripped] : Dir["#{path}/#{stripped}"]
|
1289
1341
|
end
|
1290
1342
|
|
1291
1343
|
def extract_location(path)
|
1292
|
-
|
1293
|
-
|
1344
|
+
match = /^(.*?)((?:\:\d+)+)$/.match(path)
|
1345
|
+
|
1346
|
+
if match
|
1347
|
+
captures = match.captures
|
1348
|
+
path, lines = captures[0], captures[1][1..-1].split(":").map { |n| n.to_i }
|
1294
1349
|
filter_manager.add_location path, lines
|
1295
1350
|
end
|
1351
|
+
|
1296
1352
|
path
|
1297
1353
|
end
|
1298
1354
|
|
@@ -1301,16 +1357,16 @@ module RSpec
|
|
1301
1357
|
end
|
1302
1358
|
|
1303
1359
|
def value_for(key, default=nil)
|
1304
|
-
@preferred_options.
|
1360
|
+
@preferred_options.key?(key) ? @preferred_options[key] : default
|
1305
1361
|
end
|
1306
1362
|
|
1307
1363
|
def assert_no_example_groups_defined(config_option)
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1364
|
+
return unless RSpec.world.example_groups.any?
|
1365
|
+
|
1366
|
+
raise MustBeConfiguredBeforeExampleGroupsError.new(
|
1367
|
+
"RSpec's #{config_option} configuration option must be configured before " \
|
1368
|
+
"any example groups are defined, but you have already defined a group."
|
1369
|
+
)
|
1314
1370
|
end
|
1315
1371
|
|
1316
1372
|
def output_to_tty?(output=output_stream)
|
@@ -1339,6 +1395,16 @@ module RSpec
|
|
1339
1395
|
def rspec_expectations_loaded?
|
1340
1396
|
defined?(RSpec::Expectations.configuration)
|
1341
1397
|
end
|
1398
|
+
|
1399
|
+
def update_pattern_attr(name, value)
|
1400
|
+
if @spec_files_loaded
|
1401
|
+
RSpec.warning "Configuring `#{name}` to #{value} has no effect since RSpec has already loaded the spec files."
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
instance_variable_set(:"@#{name}", value)
|
1405
|
+
@files_to_run = nil
|
1406
|
+
end
|
1342
1407
|
end
|
1408
|
+
# rubocop:enable Style/ClassLength
|
1343
1409
|
end
|
1344
1410
|
end
|