rspec-core 3.5.1 → 3.6.0.beta1
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +62 -2
- data/lib/rspec/core/bisect/server.rb +6 -1
- data/lib/rspec/core/configuration.rb +68 -10
- data/lib/rspec/core/drb.rb +2 -0
- data/lib/rspec/core/example.rb +11 -9
- data/lib/rspec/core/example_group.rb +10 -4
- data/lib/rspec/core/formatters/base_text_formatter.rb +0 -1
- data/lib/rspec/core/formatters/console_codes.rb +7 -4
- data/lib/rspec/core/formatters/documentation_formatter.rb +1 -0
- data/lib/rspec/core/formatters/exception_presenter.rb +3 -1
- data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
- data/lib/rspec/core/formatters.rb +1 -1
- data/lib/rspec/core/hooks.rb +1 -8
- data/lib/rspec/core/invocations.rb +22 -4
- data/lib/rspec/core/metadata.rb +1 -0
- data/lib/rspec/core/metadata_filter.rb +12 -17
- data/lib/rspec/core/notifications.rb +3 -3
- data/lib/rspec/core/option_parser.rb +32 -12
- data/lib/rspec/core/project_initializer/.rspec +0 -1
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +1 -1
- data/lib/rspec/core/rake_task.rb +1 -0
- data/lib/rspec/core/reporter.rb +12 -0
- data/lib/rspec/core/runner.rb +10 -3
- data/lib/rspec/core/shared_example_group.rb +33 -10
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +10 -0
- data/lib/rspec/core.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +9 -9
- 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: 9750d19aad7f7ef5eb954f4f6a9bc4730d7a09c7
|
|
4
|
+
data.tar.gz: 64fe3413f9233665ca9e9ed11f08c0053b3024c9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4565a663755384105496c948d14b93fa0bc8fb752ac3e2f2c201f42c5c463ac19cccbf3cddc8cdf025b337d46f361e8fc9a385fd5ffb5be3eaa02804a937c132
|
|
7
|
+
data.tar.gz: eb1bb367afa8fd11bfb7e838df3fe933edff6a4bdfaa0b649ccbc9ce24b294ac1a94e37bd51c01b8522c816ba8ad0ea3a99bd0aaeebd99c49c6b96928c6093d9
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/Changelog.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
+
### 3.6.0.beta1 / 2016-10-09
|
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.4...v3.6.0.beta1)
|
|
3
|
+
|
|
4
|
+
Enhancements:
|
|
5
|
+
|
|
6
|
+
* Warn when duplicate shared examples definitions are loaded due to being
|
|
7
|
+
defined in files matching the spec pattern (e.g. `_spec.rb`) (#2278, Devon Estes)
|
|
8
|
+
* Improve metadata filtering so that it can match against any object
|
|
9
|
+
that implements `===` instead of treating regular expressions as
|
|
10
|
+
special. (Myron Marston, #2294)
|
|
11
|
+
* Improve `rspec -v` so that it prints out the versions of each part of
|
|
12
|
+
RSpec to prevent confusion. (Myron Marston, #2304)
|
|
13
|
+
* Add `config.fail_if_no_examples` option which causes RSpec to fail if
|
|
14
|
+
no examples are found. (Ewa Czechowska, #2302)
|
|
15
|
+
* Nicely format errors encountered while loading spec files.
|
|
16
|
+
(Myron Marston, #2323)
|
|
17
|
+
* Improve the API for enabling and disabling color output (Josh
|
|
18
|
+
Justice, #2321):
|
|
19
|
+
* Automatically enable color if the output is a TTY, since color is
|
|
20
|
+
nearly always desirable if the output can handle it.
|
|
21
|
+
* Introduce new CLI flag to force color on (`--force-color`), even
|
|
22
|
+
if the output is not a TTY. `--no-color` continues to work as well.
|
|
23
|
+
* Introduce `config.color_mode` for configuring the color from Ruby.
|
|
24
|
+
`:automatic` is the default and will produce color if the output is
|
|
25
|
+
a TTY. `:on` forces it on and `:off` forces it off.
|
|
26
|
+
|
|
27
|
+
### 3.5.4 / 2016-09-30
|
|
28
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.3...v3.5.4)
|
|
29
|
+
|
|
30
|
+
Bug Fixes:
|
|
31
|
+
|
|
32
|
+
* Remove accumulated `ExampleGroup` constants when reseting RSpec,
|
|
33
|
+
preventing a memory leak. (TravisSpangle, #2328)
|
|
34
|
+
|
|
35
|
+
### 3.5.3 / 2016-09-02
|
|
36
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.2...v3.5.3)
|
|
37
|
+
|
|
38
|
+
Bug Fixes:
|
|
39
|
+
|
|
40
|
+
* When applying shared group metadata to a host group, overwrite
|
|
41
|
+
conflicting keys if the value in the host group was inherited from
|
|
42
|
+
a parent group instead of being specified at that level.
|
|
43
|
+
(Myron Marston, #2307)
|
|
44
|
+
* Handle errors in `:suite` hooks and provide the same nicely formatted
|
|
45
|
+
output as errors that happen in examples. (Myron Marston, #2316)
|
|
46
|
+
* Set the exit status to non-zero when an error occurs in an
|
|
47
|
+
`after(:context)` hook. (Myron Marston, #2320)
|
|
48
|
+
|
|
49
|
+
### 3.5.2 / 2016-07-28
|
|
50
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.1...v3.5.2)
|
|
51
|
+
|
|
52
|
+
Bug Fixes:
|
|
53
|
+
|
|
54
|
+
* Wait to report `example_finished` until the example's `execution_result`
|
|
55
|
+
has been completely filled in. (Myron Marston, #2291)
|
|
56
|
+
* Make sure example block is still available when using `duplicate_with`
|
|
57
|
+
to clone examples. (bootstraponline, #2298)
|
|
58
|
+
* Don't include the default `--pattern` in the Rake task when
|
|
59
|
+
`rspec_opts` specifies its own. (Jon Rowe, #2305)
|
|
60
|
+
|
|
1
61
|
### 3.5.1 / 2016-07-06
|
|
2
62
|
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.0...v3.5.1)
|
|
3
63
|
|
|
@@ -1829,7 +1889,7 @@ project's root directory or in your home directory:
|
|
|
1829
1889
|
|
|
1830
1890
|
require "autotest/bundler"
|
|
1831
1891
|
|
|
1832
|
-
Now you can just type 'autotest' on the
|
|
1892
|
+
Now you can just type 'autotest' on the command line and it will work as you expect.
|
|
1833
1893
|
|
|
1834
1894
|
If you don't want 'bundle exec', there is nothing you have to do.
|
|
1835
1895
|
|
|
@@ -2017,7 +2077,7 @@ Bug fixes
|
|
|
2017
2077
|
Enhancements
|
|
2018
2078
|
|
|
2019
2079
|
* implicitly require unknown formatters so you don't have to require the file
|
|
2020
|
-
explicitly on the
|
|
2080
|
+
explicitly on the command line (Michael Grosser)
|
|
2021
2081
|
* add --out/-o option to assign output target
|
|
2022
2082
|
* added fail_fast configuration option to abort on first failure
|
|
2023
2083
|
* support a Hash subject (its([:key]) { should == value }) (Josep M. Bach)
|
|
@@ -25,7 +25,12 @@ module RSpec
|
|
|
25
25
|
self.files_or_directories_to_run = files_or_directories_to_run
|
|
26
26
|
self.latest_run_results = nil
|
|
27
27
|
run_output = yield
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
if latest_run_results.nil? || latest_run_results.all_example_ids.empty?
|
|
30
|
+
raise_bisect_failed(run_output)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
latest_run_results
|
|
29
34
|
end
|
|
30
35
|
|
|
31
36
|
def start
|
|
@@ -199,6 +199,10 @@ module RSpec
|
|
|
199
199
|
# The exit code to return if there are any failures (default: 1).
|
|
200
200
|
add_setting :failure_exit_code
|
|
201
201
|
|
|
202
|
+
# @macro add_setting
|
|
203
|
+
# Whether or not to fail when there are no RSpec examples (default: false).
|
|
204
|
+
add_setting :fail_if_no_examples
|
|
205
|
+
|
|
202
206
|
# @macro define_reader
|
|
203
207
|
# Indicates files configured to be required.
|
|
204
208
|
define_reader :requires
|
|
@@ -394,6 +398,7 @@ module RSpec
|
|
|
394
398
|
add_setting :max_displayed_failure_line_count
|
|
395
399
|
|
|
396
400
|
# @private
|
|
401
|
+
# @deprecated Use {#color_mode} = :on, instead of {#color} with {#tty}
|
|
397
402
|
add_setting :tty
|
|
398
403
|
# @private
|
|
399
404
|
attr_writer :files_to_run
|
|
@@ -422,9 +427,11 @@ module RSpec
|
|
|
422
427
|
@files_or_directories_to_run = []
|
|
423
428
|
@loaded_spec_files = Set.new
|
|
424
429
|
@color = false
|
|
430
|
+
@color_mode = :automatic
|
|
425
431
|
@pattern = '**{,/*/**}/*_spec.rb'
|
|
426
432
|
@exclude_pattern = ''
|
|
427
433
|
@failure_exit_code = 1
|
|
434
|
+
@fail_if_no_examples = false
|
|
428
435
|
@spec_files_loaded = false
|
|
429
436
|
|
|
430
437
|
@backtrace_formatter = BacktraceFormatter.new
|
|
@@ -773,24 +780,54 @@ module RSpec
|
|
|
773
780
|
@backtrace_formatter.full_backtrace = true_or_false
|
|
774
781
|
end
|
|
775
782
|
|
|
776
|
-
#
|
|
777
|
-
#
|
|
783
|
+
# Enables color output if the output is a TTY. As of RSpec 3.6, this is
|
|
784
|
+
# the default behavior and this option is retained only for backwards
|
|
785
|
+
# compatibility.
|
|
778
786
|
#
|
|
787
|
+
# @deprecated No longer recommended because of complex behavior. Instead,
|
|
788
|
+
# rely on the fact that TTYs will display color by default, or set
|
|
789
|
+
# {#color_mode} to :on to display color on a non-TTY output.
|
|
790
|
+
# @see color_mode
|
|
779
791
|
# @see color_enabled?
|
|
780
792
|
# @return [Boolean]
|
|
781
793
|
def color
|
|
782
794
|
value_for(:color) { @color }
|
|
783
795
|
end
|
|
784
796
|
|
|
797
|
+
# The mode for determining whether to display output in color. One of:
|
|
798
|
+
#
|
|
799
|
+
# - :automatic - the output will be in color if the output is a TTY (the
|
|
800
|
+
# default)
|
|
801
|
+
# - :on - the output will be in color, whether or not the output is a TTY
|
|
802
|
+
# - :off - the output will not be in color
|
|
803
|
+
#
|
|
804
|
+
# @see color_enabled?
|
|
805
|
+
# @return [Boolean]
|
|
806
|
+
def color_mode
|
|
807
|
+
value_for(:color_mode) { @color_mode }
|
|
808
|
+
end
|
|
809
|
+
|
|
785
810
|
# Check if color is enabled for a particular output.
|
|
786
811
|
# @param output [IO] an output stream to use, defaults to the current
|
|
787
812
|
# `output_stream`
|
|
788
813
|
# @return [Boolean]
|
|
789
814
|
def color_enabled?(output=output_stream)
|
|
790
|
-
|
|
815
|
+
case color_mode
|
|
816
|
+
when :on then true
|
|
817
|
+
when :off then false
|
|
818
|
+
else # automatic
|
|
819
|
+
output_to_tty?(output) || (color && tty?)
|
|
820
|
+
end
|
|
791
821
|
end
|
|
792
822
|
|
|
823
|
+
# Set the color mode.
|
|
824
|
+
attr_writer :color_mode
|
|
825
|
+
|
|
793
826
|
# Toggle output color.
|
|
827
|
+
#
|
|
828
|
+
# @deprecated No longer recommended because of complex behavior. Instead,
|
|
829
|
+
# rely on the fact that TTYs will display color by default, or set
|
|
830
|
+
# {:color_mode} to :on to display color on a non-TTY output.
|
|
794
831
|
attr_writer :color
|
|
795
832
|
|
|
796
833
|
# @private
|
|
@@ -1432,7 +1469,7 @@ module RSpec
|
|
|
1432
1469
|
|
|
1433
1470
|
files_to_run.uniq.each do |f|
|
|
1434
1471
|
file = File.expand_path(f)
|
|
1435
|
-
|
|
1472
|
+
load_spec_file_handling_errors(file)
|
|
1436
1473
|
loaded_spec_files << file
|
|
1437
1474
|
end
|
|
1438
1475
|
|
|
@@ -1830,12 +1867,11 @@ module RSpec
|
|
|
1830
1867
|
def with_suite_hooks
|
|
1831
1868
|
return yield if dry_run?
|
|
1832
1869
|
|
|
1833
|
-
hook_context = SuiteHookContext.new
|
|
1834
1870
|
begin
|
|
1835
|
-
|
|
1871
|
+
run_suite_hooks("a `before(:suite)` hook", @before_suite_hooks)
|
|
1836
1872
|
yield
|
|
1837
1873
|
ensure
|
|
1838
|
-
|
|
1874
|
+
run_suite_hooks("an `after(:suite)` hook", @after_suite_hooks)
|
|
1839
1875
|
end
|
|
1840
1876
|
end
|
|
1841
1877
|
|
|
@@ -1860,6 +1896,14 @@ module RSpec
|
|
|
1860
1896
|
|
|
1861
1897
|
private
|
|
1862
1898
|
|
|
1899
|
+
def load_spec_file_handling_errors(file)
|
|
1900
|
+
load file
|
|
1901
|
+
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
|
|
1902
|
+
relative_file = Metadata.relative_path(file)
|
|
1903
|
+
reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.")
|
|
1904
|
+
RSpec.world.wants_to_quit = true
|
|
1905
|
+
end
|
|
1906
|
+
|
|
1863
1907
|
def handle_suite_hook(scope, meta)
|
|
1864
1908
|
return nil unless scope == :suite
|
|
1865
1909
|
|
|
@@ -1875,8 +1919,22 @@ module RSpec
|
|
|
1875
1919
|
yield
|
|
1876
1920
|
end
|
|
1877
1921
|
|
|
1878
|
-
def
|
|
1879
|
-
|
|
1922
|
+
def run_suite_hooks(hook_description, hooks)
|
|
1923
|
+
context = SuiteHookContext.new(hook_description, reporter)
|
|
1924
|
+
|
|
1925
|
+
hooks.each do |hook|
|
|
1926
|
+
begin
|
|
1927
|
+
hook.run(context)
|
|
1928
|
+
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
|
|
1929
|
+
context.set_exception(ex)
|
|
1930
|
+
|
|
1931
|
+
# Do not run subsequent `before` hooks if one fails.
|
|
1932
|
+
# But for `after` hooks, we run them all so that all
|
|
1933
|
+
# cleanup bits get a chance to complete, minimizing the
|
|
1934
|
+
# chance that resources get left behind.
|
|
1935
|
+
break if hooks.equal?(@before_suite_hooks)
|
|
1936
|
+
end
|
|
1937
|
+
end
|
|
1880
1938
|
end
|
|
1881
1939
|
|
|
1882
1940
|
def get_files_to_run(paths)
|
|
@@ -1979,7 +2037,7 @@ module RSpec
|
|
|
1979
2037
|
end
|
|
1980
2038
|
|
|
1981
2039
|
def output_to_tty?(output=output_stream)
|
|
1982
|
-
|
|
2040
|
+
output.respond_to?(:tty?) && output.tty?
|
|
1983
2041
|
end
|
|
1984
2042
|
|
|
1985
2043
|
def conditionally_disable_mocks_monkey_patching
|
data/lib/rspec/core/drb.rb
CHANGED
|
@@ -41,6 +41,8 @@ module RSpec
|
|
|
41
41
|
def options
|
|
42
42
|
argv = []
|
|
43
43
|
argv << "--color" if @submitted_options[:color]
|
|
44
|
+
argv << "--force-color" if @submitted_options[:color_mode] == :on
|
|
45
|
+
argv << "--no-color" if @submitted_options[:color_mode] == :off
|
|
44
46
|
argv << "--profile" if @submitted_options[:profile_examples]
|
|
45
47
|
argv << "--backtrace" if @submitted_options[:full_backtrace]
|
|
46
48
|
argv << "--tty" if @submitted_options[:tty]
|
data/lib/rspec/core/example.rb
CHANGED
|
@@ -138,8 +138,10 @@ module RSpec
|
|
|
138
138
|
|
|
139
139
|
# don't clone the example group because the new example
|
|
140
140
|
# must belong to the same example group (not a clone).
|
|
141
|
+
#
|
|
142
|
+
# block is nil in new_metadata so we have to get it from metadata.
|
|
141
143
|
Example.new(example_group, description.clone,
|
|
142
|
-
new_metadata,
|
|
144
|
+
new_metadata, metadata[:block])
|
|
143
145
|
end
|
|
144
146
|
|
|
145
147
|
# @private
|
|
@@ -461,15 +463,14 @@ module RSpec
|
|
|
461
463
|
def finish(reporter)
|
|
462
464
|
pending_message = execution_result.pending_message
|
|
463
465
|
|
|
464
|
-
reporter.example_finished(self)
|
|
465
466
|
if @exception
|
|
466
|
-
record_finished :failed
|
|
467
467
|
execution_result.exception = @exception
|
|
468
|
+
record_finished :failed
|
|
468
469
|
reporter.example_failed self
|
|
469
470
|
false
|
|
470
471
|
elsif pending_message
|
|
471
|
-
record_finished :pending
|
|
472
472
|
execution_result.pending_message = pending_message
|
|
473
|
+
record_finished :pending
|
|
473
474
|
reporter.example_pending self
|
|
474
475
|
true
|
|
475
476
|
else
|
|
@@ -481,6 +482,7 @@ module RSpec
|
|
|
481
482
|
|
|
482
483
|
def record_finished(status)
|
|
483
484
|
execution_result.record_finished(status, clock.now)
|
|
485
|
+
reporter.example_finished(self)
|
|
484
486
|
end
|
|
485
487
|
|
|
486
488
|
def run_before_example
|
|
@@ -630,16 +632,16 @@ module RSpec
|
|
|
630
632
|
# @private
|
|
631
633
|
# Provides an execution context for before/after :suite hooks.
|
|
632
634
|
class SuiteHookContext < Example
|
|
633
|
-
def initialize
|
|
634
|
-
super(AnonymousExampleGroup,
|
|
635
|
+
def initialize(hook_description, reporter)
|
|
636
|
+
super(AnonymousExampleGroup, hook_description, {})
|
|
635
637
|
@example_group_instance = AnonymousExampleGroup.new
|
|
638
|
+
@reporter = reporter
|
|
636
639
|
end
|
|
637
640
|
|
|
638
641
|
# rubocop:disable Style/AccessorMethodName
|
|
639
|
-
|
|
640
|
-
# To ensure we don't silence errors.
|
|
641
642
|
def set_exception(exception)
|
|
642
|
-
|
|
643
|
+
reporter.notify_non_example_exception(exception, "An error occurred in #{description}.")
|
|
644
|
+
RSpec.world.wants_to_quit = true
|
|
643
645
|
end
|
|
644
646
|
# rubocop:enable Style/AccessorMethodName
|
|
645
647
|
end
|
|
@@ -415,10 +415,10 @@ module RSpec
|
|
|
415
415
|
# not be applied where they should.
|
|
416
416
|
registration_collection << self
|
|
417
417
|
|
|
418
|
-
user_metadata = Metadata.build_hash_from(args)
|
|
418
|
+
@user_metadata = Metadata.build_hash_from(args)
|
|
419
419
|
|
|
420
420
|
@metadata = Metadata::ExampleGroupHash.create(
|
|
421
|
-
superclass_metadata, user_metadata,
|
|
421
|
+
superclass_metadata, @user_metadata,
|
|
422
422
|
superclass.method(:next_runnable_index_for),
|
|
423
423
|
description, *args, &example_group_block
|
|
424
424
|
)
|
|
@@ -705,8 +705,8 @@ module RSpec
|
|
|
705
705
|
|
|
706
706
|
# @private
|
|
707
707
|
def self.update_inherited_metadata(updates)
|
|
708
|
-
metadata.update(updates) do |
|
|
709
|
-
existing_group_value
|
|
708
|
+
metadata.update(updates) do |key, existing_group_value, new_inherited_value|
|
|
709
|
+
@user_metadata.key?(key) ? existing_group_value : new_inherited_value
|
|
710
710
|
end
|
|
711
711
|
|
|
712
712
|
RSpec.configuration.configure_group(self)
|
|
@@ -827,6 +827,12 @@ module RSpec
|
|
|
827
827
|
const_scope
|
|
828
828
|
end
|
|
829
829
|
|
|
830
|
+
def self.remove_all_constants
|
|
831
|
+
constants.each do |constant|
|
|
832
|
+
__send__(:remove_const, constant)
|
|
833
|
+
end
|
|
834
|
+
end
|
|
835
|
+
|
|
830
836
|
def self.base_name_for(group)
|
|
831
837
|
return "Anonymous" if group.description.empty?
|
|
832
838
|
|
|
@@ -23,9 +23,12 @@ module RSpec
|
|
|
23
23
|
module_function
|
|
24
24
|
|
|
25
25
|
# @private
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
def config_colors_to_methods
|
|
27
|
+
@config_colors_to_methods ||=
|
|
28
|
+
Configuration.instance_methods.grep(/_color\z/).inject({}) do |hash, method|
|
|
29
|
+
hash[method.to_s.sub(/_color\z/, '').to_sym] = method
|
|
30
|
+
hash
|
|
31
|
+
end
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
# Fetches the correct code for the supplied symbol, or checks
|
|
@@ -34,7 +37,7 @@ module RSpec
|
|
|
34
37
|
# @param code_or_symbol [Symbol, Fixnum] Symbol or code to check
|
|
35
38
|
# @return [Fixnum] a console code
|
|
36
39
|
def console_code_for(code_or_symbol)
|
|
37
|
-
if (config_method =
|
|
40
|
+
if (config_method = config_colors_to_methods[code_or_symbol])
|
|
38
41
|
console_code_for RSpec.configuration.__send__(config_method)
|
|
39
42
|
elsif VT100_CODE_VALUES.key?(code_or_symbol)
|
|
40
43
|
code_or_symbol
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
RSpec::Support.require_rspec_core "formatters/console_codes"
|
|
2
3
|
RSpec::Support.require_rspec_core "formatters/snippet_extractor"
|
|
3
4
|
RSpec::Support.require_rspec_support "encoded_string"
|
|
4
5
|
|
|
@@ -122,7 +123,8 @@ module RSpec
|
|
|
122
123
|
end
|
|
123
124
|
|
|
124
125
|
def indent_lines(lines, failure_number)
|
|
125
|
-
alignment_basis =
|
|
126
|
+
alignment_basis = ' ' * @indentation
|
|
127
|
+
alignment_basis << "#{failure_number}) " if failure_number
|
|
126
128
|
indentation = ' ' * alignment_basis.length
|
|
127
129
|
|
|
128
130
|
lines.each_with_index.map do |line, index|
|
|
@@ -24,7 +24,7 @@ RSpec::Support.require_rspec_support "directory_maker"
|
|
|
24
24
|
# ## Custom Formatters
|
|
25
25
|
#
|
|
26
26
|
# You can tell RSpec to use a custom formatter by passing its path and name to
|
|
27
|
-
# the `rspec`
|
|
27
|
+
# the `rspec` command. For example, if you define MyCustomFormatter in
|
|
28
28
|
# path/to/my_custom_formatter.rb, you would type this command:
|
|
29
29
|
#
|
|
30
30
|
# rspec --require path/to/my_custom_formatter.rb --format MyCustomFormatter
|
data/lib/rspec/core/hooks.rb
CHANGED
|
@@ -365,14 +365,7 @@ module RSpec
|
|
|
365
365
|
def run(example)
|
|
366
366
|
example.instance_exec(example, &block)
|
|
367
367
|
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => e
|
|
368
|
-
|
|
369
|
-
RSpec.configuration.reporter.message <<-EOS
|
|
370
|
-
|
|
371
|
-
An error occurred in an `after(:context)` hook.
|
|
372
|
-
#{e.class}: #{e.message}
|
|
373
|
-
occurred at #{e.backtrace.first}
|
|
374
|
-
|
|
375
|
-
EOS
|
|
368
|
+
RSpec.configuration.reporter.notify_non_example_exception(e, "An error occurred in an `after(:context)` hook.")
|
|
376
369
|
end
|
|
377
370
|
end
|
|
378
371
|
|
|
@@ -49,16 +49,34 @@ module RSpec
|
|
|
49
49
|
# @private
|
|
50
50
|
class PrintVersion
|
|
51
51
|
def call(_options, _err, out)
|
|
52
|
-
|
|
52
|
+
overall_version = RSpec::Core::Version::STRING
|
|
53
|
+
unless overall_version =~ /[a-zA-Z]+/
|
|
54
|
+
overall_version = overall_version.split('.').first(2).join('.')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
out.puts "RSpec #{overall_version}"
|
|
58
|
+
|
|
59
|
+
[:Core, :Expectations, :Mocks, :Rails, :Support].each do |const_name|
|
|
60
|
+
lib_name = const_name.to_s.downcase
|
|
61
|
+
begin
|
|
62
|
+
require "rspec/#{lib_name}/version"
|
|
63
|
+
rescue LoadError
|
|
64
|
+
# Not worth mentioning libs that are not installed
|
|
65
|
+
nil
|
|
66
|
+
else
|
|
67
|
+
out.puts " - rspec-#{lib_name} #{RSpec.const_get(const_name)::Version::STRING}"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
53
71
|
0
|
|
54
72
|
end
|
|
55
73
|
end
|
|
56
74
|
|
|
57
75
|
# @private
|
|
58
|
-
PrintHelp = Struct.new(:parser, :
|
|
76
|
+
PrintHelp = Struct.new(:parser, :hidden_options) do
|
|
59
77
|
def call(_options, _err, out)
|
|
60
|
-
# Removing the
|
|
61
|
-
out.puts parser.to_s.gsub(/^\s+(#{
|
|
78
|
+
# Removing the hidden options from the output.
|
|
79
|
+
out.puts parser.to_s.gsub(/^\s+(#{hidden_options.join('|')})\b.*$\n/, '')
|
|
62
80
|
0
|
|
63
81
|
end
|
|
64
82
|
end
|
data/lib/rspec/core/metadata.rb
CHANGED
|
@@ -178,6 +178,7 @@ module RSpec
|
|
|
178
178
|
|
|
179
179
|
def build_description_from(parent_description=nil, my_description=nil)
|
|
180
180
|
return parent_description.to_s unless my_description
|
|
181
|
+
return my_description.to_s if parent_description.to_s == ''
|
|
181
182
|
separator = description_separator(parent_description, my_description)
|
|
182
183
|
(parent_description.to_s + separator) << my_description.to_s
|
|
183
184
|
end
|
|
@@ -13,24 +13,19 @@ module RSpec
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# @private
|
|
16
|
-
def filter_applies?(key,
|
|
16
|
+
def filter_applies?(key, filter_value, metadata)
|
|
17
17
|
silence_metadata_example_group_deprecations do
|
|
18
|
-
return location_filter_applies?(
|
|
19
|
-
return id_filter_applies?(
|
|
20
|
-
return filters_apply?(key,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
when Proc
|
|
30
|
-
proc_filter_applies?(key, value, metadata)
|
|
31
|
-
else
|
|
32
|
-
metadata[key].to_s == value.to_s
|
|
33
|
-
end
|
|
18
|
+
return location_filter_applies?(filter_value, metadata) if key == :locations
|
|
19
|
+
return id_filter_applies?(filter_value, metadata) if key == :ids
|
|
20
|
+
return filters_apply?(key, filter_value, metadata) if Hash === filter_value
|
|
21
|
+
|
|
22
|
+
meta_value = metadata.fetch(key) { return false }
|
|
23
|
+
|
|
24
|
+
return true if TrueClass === filter_value && meta_value
|
|
25
|
+
return proc_filter_applies?(key, filter_value, metadata) if Proc === filter_value
|
|
26
|
+
return filter_applies_to_any_value?(key, filter_value, metadata) if Array === meta_value
|
|
27
|
+
|
|
28
|
+
filter_value === meta_value || filter_value.to_s == meta_value.to_s
|
|
34
29
|
end
|
|
35
30
|
end
|
|
36
31
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
RSpec::Support.require_rspec_core "formatters/console_codes"
|
|
1
2
|
RSpec::Support.require_rspec_core "formatters/exception_presenter"
|
|
2
3
|
RSpec::Support.require_rspec_core "formatters/helpers"
|
|
3
4
|
RSpec::Support.require_rspec_core "shell_escape"
|
|
@@ -51,8 +52,7 @@ module RSpec::Core
|
|
|
51
52
|
FailedExampleNotification
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
klass.new(example, exception_presenter)
|
|
55
|
+
klass.new(example)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
private_class_method :new
|
|
@@ -202,7 +202,7 @@ module RSpec::Core
|
|
|
202
202
|
|
|
203
203
|
private
|
|
204
204
|
|
|
205
|
-
def initialize(example, exception_presenter)
|
|
205
|
+
def initialize(example, exception_presenter=Formatters::ExceptionPresenter::Factory.new(example).build)
|
|
206
206
|
@exception_presenter = exception_presenter
|
|
207
207
|
super(example)
|
|
208
208
|
end
|
|
@@ -39,6 +39,8 @@ module RSpec::Core
|
|
|
39
39
|
# rubocop:disable PerceivedComplexity
|
|
40
40
|
def parser(options)
|
|
41
41
|
OptionParser.new do |parser|
|
|
42
|
+
parser.summary_width = 34
|
|
43
|
+
|
|
42
44
|
parser.banner = "Usage: rspec [options] [files or directories]\n\n"
|
|
43
45
|
|
|
44
46
|
parser.on('-I PATH', 'Specify PATH to add to $LOAD_PATH (may be used more than once).') do |dirs|
|
|
@@ -93,11 +95,6 @@ module RSpec::Core
|
|
|
93
95
|
options[:failure_exit_code] = code
|
|
94
96
|
end
|
|
95
97
|
|
|
96
|
-
parser.on('--dry-run', 'Print the formatter output of your suite without',
|
|
97
|
-
' running any examples or hooks') do |_o|
|
|
98
|
-
options[:dry_run] = true
|
|
99
|
-
end
|
|
100
|
-
|
|
101
98
|
parser.on('-X', '--[no-]drb', 'Run examples via DRb.') do |use_drb|
|
|
102
99
|
options[:drb] = use_drb
|
|
103
100
|
options[:runner] = RSpec::Core::Invocations::DRbWithFallback.new if use_drb
|
|
@@ -107,10 +104,6 @@ module RSpec::Core
|
|
|
107
104
|
options[:drb_port] = o.to_i
|
|
108
105
|
end
|
|
109
106
|
|
|
110
|
-
parser.on('--init', 'Initialize your project with RSpec.') do |_cmd|
|
|
111
|
-
options[:runner] = RSpec::Core::Invocations::InitializeProject.new
|
|
112
|
-
end
|
|
113
|
-
|
|
114
107
|
parser.separator("\n **** Output ****\n\n")
|
|
115
108
|
|
|
116
109
|
parser.on('-f', '--format FORMATTER', 'Choose a formatter.',
|
|
@@ -140,8 +133,24 @@ module RSpec::Core
|
|
|
140
133
|
options[:full_backtrace] = true
|
|
141
134
|
end
|
|
142
135
|
|
|
143
|
-
parser.on('-c', '--
|
|
144
|
-
|
|
136
|
+
parser.on('-c', '--color', '--colour', '') do |_o|
|
|
137
|
+
# flag will be excluded from `--help` output because it is deprecated
|
|
138
|
+
options[:color] = true
|
|
139
|
+
options[:color_mode] = :automatic
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
parser.on('--force-color', '--force-colour', 'Force the output to be in color, even if the output is not a TTY') do |_o|
|
|
143
|
+
if options[:color_mode] == :off
|
|
144
|
+
abort "Please only use one of `--force-color` and `--no-color`"
|
|
145
|
+
end
|
|
146
|
+
options[:color_mode] = :on
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
parser.on('--no-color', '--no-colour', 'Force the output to not be in color, even if the output is a TTY') do |_o|
|
|
150
|
+
if options[:color_mode] == :on
|
|
151
|
+
abort "Please only use one of --force-color and --no-color"
|
|
152
|
+
end
|
|
153
|
+
options[:color_mode] = :off
|
|
145
154
|
end
|
|
146
155
|
|
|
147
156
|
parser.on('-p', '--[no-]profile [COUNT]',
|
|
@@ -163,6 +172,11 @@ module RSpec::Core
|
|
|
163
172
|
end
|
|
164
173
|
end
|
|
165
174
|
|
|
175
|
+
parser.on('--dry-run', 'Print the formatter output of your suite without',
|
|
176
|
+
' running any examples or hooks') do |_o|
|
|
177
|
+
options[:dry_run] = true
|
|
178
|
+
end
|
|
179
|
+
|
|
166
180
|
parser.on('-w', '--warnings', 'Enable ruby warnings') do
|
|
167
181
|
$VERBOSE = true
|
|
168
182
|
end
|
|
@@ -244,6 +258,10 @@ FILTERING
|
|
|
244
258
|
|
|
245
259
|
parser.separator("\n **** Utility ****\n\n")
|
|
246
260
|
|
|
261
|
+
parser.on('--init', 'Initialize your project with RSpec.') do |_cmd|
|
|
262
|
+
options[:runner] = RSpec::Core::Invocations::InitializeProject.new
|
|
263
|
+
end
|
|
264
|
+
|
|
247
265
|
parser.on('-v', '--version', 'Display the version.') do
|
|
248
266
|
options[:runner] = RSpec::Core::Invocations::PrintVersion.new
|
|
249
267
|
end
|
|
@@ -256,8 +274,10 @@ FILTERING
|
|
|
256
274
|
# trigger --default-path.
|
|
257
275
|
invalid_options = %w[-d --I]
|
|
258
276
|
|
|
277
|
+
hidden_options = invalid_options + %w[-c]
|
|
278
|
+
|
|
259
279
|
parser.on_tail('-h', '--help', "You're looking at it.") do
|
|
260
|
-
options[:runner] = RSpec::Core::Invocations::PrintHelp.new(parser,
|
|
280
|
+
options[:runner] = RSpec::Core::Invocations::PrintHelp.new(parser, hidden_options)
|
|
261
281
|
end
|
|
262
282
|
|
|
263
283
|
# This prevents usage of the invalid_options.
|
|
@@ -80,7 +80,7 @@ RSpec.configure do |config|
|
|
|
80
80
|
# Use the documentation formatter for detailed output,
|
|
81
81
|
# unless a formatter has already been configured
|
|
82
82
|
# (e.g. via a command-line flag).
|
|
83
|
-
config.default_formatter =
|
|
83
|
+
config.default_formatter = "doc"
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
# Print the 10 slowest examples and example groups at the
|
data/lib/rspec/core/rake_task.rb
CHANGED
|
@@ -102,6 +102,7 @@ module RSpec
|
|
|
102
102
|
if ENV['SPEC']
|
|
103
103
|
FileList[ENV['SPEC']].sort
|
|
104
104
|
elsif String === pattern && !File.exist?(pattern)
|
|
105
|
+
return if rspec_opts =~ /--pattern/
|
|
105
106
|
"--pattern #{escape pattern}"
|
|
106
107
|
else
|
|
107
108
|
# Before RSpec 3.1, we used `FileList` to get the list of matched
|
data/lib/rspec/core/reporter.rb
CHANGED
|
@@ -151,6 +151,18 @@ module RSpec::Core
|
|
|
151
151
|
notify :deprecation, Notifications::DeprecationNotification.from_hash(hash)
|
|
152
152
|
end
|
|
153
153
|
|
|
154
|
+
# @private
|
|
155
|
+
# Provides a way to notify of an exception that is not tied to any
|
|
156
|
+
# particular example (such as an exception encountered in a :suite hook).
|
|
157
|
+
# Exceptions will be formatted the same way they normally are.
|
|
158
|
+
def notify_non_example_exception(exception, context_description)
|
|
159
|
+
@configuration.world.non_example_failure = true
|
|
160
|
+
|
|
161
|
+
example = Example.new(AnonymousExampleGroup, context_description, {})
|
|
162
|
+
presenter = Formatters::ExceptionPresenter.new(exception, example, :indentation => 0)
|
|
163
|
+
message presenter.fully_formatted(nil)
|
|
164
|
+
end
|
|
165
|
+
|
|
154
166
|
# @private
|
|
155
167
|
def finish
|
|
156
168
|
close_after do
|
data/lib/rspec/core/runner.rb
CHANGED
|
@@ -108,11 +108,18 @@ module RSpec
|
|
|
108
108
|
# or the configured failure exit code (1 by default) if specs
|
|
109
109
|
# failed.
|
|
110
110
|
def run_specs(example_groups)
|
|
111
|
-
@
|
|
111
|
+
examples_count = @world.example_count(example_groups)
|
|
112
|
+
success = @configuration.reporter.report(examples_count) do |reporter|
|
|
112
113
|
@configuration.with_suite_hooks do
|
|
113
|
-
|
|
114
|
+
if examples_count == 0 && @configuration.fail_if_no_examples
|
|
115
|
+
return @configuration.failure_exit_code
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
example_groups.map { |g| g.run(reporter) }.all?
|
|
114
119
|
end
|
|
115
|
-
end
|
|
120
|
+
end && !@world.non_example_failure
|
|
121
|
+
|
|
122
|
+
success ? 0 : @configuration.failure_exit_code
|
|
116
123
|
end
|
|
117
124
|
|
|
118
125
|
private
|
|
@@ -213,20 +213,43 @@ module RSpec
|
|
|
213
213
|
|
|
214
214
|
def warn_if_key_taken(context, key, new_block)
|
|
215
215
|
existing_module = shared_example_groups[context][key]
|
|
216
|
-
|
|
217
216
|
return unless existing_module
|
|
218
217
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
218
|
+
old_definition_location = formatted_location existing_module.definition
|
|
219
|
+
new_definition_location = formatted_location new_block
|
|
220
|
+
loaded_spec_files = RSpec.configuration.loaded_spec_files
|
|
221
|
+
|
|
222
|
+
if loaded_spec_files.include?(new_definition_location) && old_definition_location == new_definition_location
|
|
223
|
+
RSpec.warn_with <<-WARNING.gsub(/^ +\|/, ''), :call_site => nil
|
|
224
|
+
|WARNING: Your shared example group, '#{key}', defined at:
|
|
225
|
+
| #{old_definition_location}
|
|
226
|
+
|was automatically loaded by RSpec because the file name
|
|
227
|
+
|matches the configured autoloading pattern (#{RSpec.configuration.pattern}),
|
|
228
|
+
|and is also being required from somewhere else. To fix this
|
|
229
|
+
|warning, either rename the file to not match the pattern, or
|
|
230
|
+
|do not explicitly require the file.
|
|
231
|
+
WARNING
|
|
232
|
+
else
|
|
233
|
+
RSpec.warn_with <<-WARNING.gsub(/^ +\|/, ''), :call_site => nil
|
|
234
|
+
|WARNING: Shared example group '#{key}' has been previously defined at:
|
|
235
|
+
| #{old_definition_location}
|
|
236
|
+
|...and you are now defining it at:
|
|
237
|
+
| #{new_definition_location}
|
|
238
|
+
|The new definition will overwrite the original one.
|
|
239
|
+
WARNING
|
|
240
|
+
end
|
|
226
241
|
end
|
|
227
242
|
|
|
228
|
-
|
|
229
|
-
block
|
|
243
|
+
if RUBY_VERSION.to_f >= 1.9
|
|
244
|
+
def formatted_location(block)
|
|
245
|
+
block.source_location.join(":")
|
|
246
|
+
end
|
|
247
|
+
else # 1.8.7
|
|
248
|
+
# :nocov:
|
|
249
|
+
def formatted_location(block)
|
|
250
|
+
block.source_location.join(":").gsub(/:in.*$/, '')
|
|
251
|
+
end
|
|
252
|
+
# :nocov:
|
|
230
253
|
end
|
|
231
254
|
|
|
232
255
|
if Proc.method_defined?(:source_location)
|
data/lib/rspec/core/version.rb
CHANGED
data/lib/rspec/core/world.rb
CHANGED
|
@@ -10,6 +10,12 @@ module RSpec
|
|
|
10
10
|
# Used internally to determine what to do when a SIGINT is received.
|
|
11
11
|
attr_accessor :wants_to_quit
|
|
12
12
|
|
|
13
|
+
# Used internally to signal that a failure outside of an example
|
|
14
|
+
# has occurred, and that therefore the exit status should indicate
|
|
15
|
+
# the run failed.
|
|
16
|
+
# @private
|
|
17
|
+
attr_accessor :non_example_failure
|
|
18
|
+
|
|
13
19
|
def initialize(configuration=RSpec.configuration)
|
|
14
20
|
@configuration = configuration
|
|
15
21
|
configuration.world = self
|
|
@@ -32,6 +38,7 @@ module RSpec
|
|
|
32
38
|
#
|
|
33
39
|
# Reset world to 'scratch' before running suite.
|
|
34
40
|
def reset
|
|
41
|
+
RSpec::ExampleGroups.remove_all_constants
|
|
35
42
|
example_groups.clear
|
|
36
43
|
@shared_example_group_registry = nil
|
|
37
44
|
end
|
|
@@ -224,6 +231,9 @@ module RSpec
|
|
|
224
231
|
# @private
|
|
225
232
|
# Provides a null implementation for initial use by configuration.
|
|
226
233
|
module Null
|
|
234
|
+
def self.non_example_failure; end
|
|
235
|
+
def self.non_example_failure=(_); end
|
|
236
|
+
|
|
227
237
|
def self.registered_example_group_files
|
|
228
238
|
[]
|
|
229
239
|
end
|
data/lib/rspec/core.rb
CHANGED
|
@@ -56,6 +56,7 @@ module RSpec
|
|
|
56
56
|
# they use the runner multiple times within the same process. Users must deal
|
|
57
57
|
# themselves with re-configuration of RSpec before run.
|
|
58
58
|
def self.reset
|
|
59
|
+
RSpec::ExampleGroups.remove_all_constants
|
|
59
60
|
@world = nil
|
|
60
61
|
@configuration = nil
|
|
61
62
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.6.0.beta1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steven Baker
|
|
@@ -46,22 +46,22 @@ cert_chain:
|
|
|
46
46
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
|
47
47
|
F3MdtaDehhjC
|
|
48
48
|
-----END CERTIFICATE-----
|
|
49
|
-
date: 2016-
|
|
49
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
|
50
50
|
dependencies:
|
|
51
51
|
- !ruby/object:Gem::Dependency
|
|
52
52
|
name: rspec-support
|
|
53
53
|
requirement: !ruby/object:Gem::Requirement
|
|
54
54
|
requirements:
|
|
55
|
-
- -
|
|
55
|
+
- - '='
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: 3.
|
|
57
|
+
version: 3.6.0.beta1
|
|
58
58
|
type: :runtime
|
|
59
59
|
prerelease: false
|
|
60
60
|
version_requirements: !ruby/object:Gem::Requirement
|
|
61
61
|
requirements:
|
|
62
|
-
- -
|
|
62
|
+
- - '='
|
|
63
63
|
- !ruby/object:Gem::Version
|
|
64
|
-
version: 3.
|
|
64
|
+
version: 3.6.0.beta1
|
|
65
65
|
- !ruby/object:Gem::Dependency
|
|
66
66
|
name: cucumber
|
|
67
67
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -275,14 +275,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
275
275
|
version: 1.8.7
|
|
276
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
277
|
requirements:
|
|
278
|
-
- - "
|
|
278
|
+
- - ">"
|
|
279
279
|
- !ruby/object:Gem::Version
|
|
280
|
-
version:
|
|
280
|
+
version: 1.3.1
|
|
281
281
|
requirements: []
|
|
282
282
|
rubyforge_project:
|
|
283
283
|
rubygems_version: 2.2.2
|
|
284
284
|
signing_key:
|
|
285
285
|
specification_version: 4
|
|
286
|
-
summary: rspec-core-3.
|
|
286
|
+
summary: rspec-core-3.6.0.beta1
|
|
287
287
|
test_files: []
|
|
288
288
|
has_rdoc:
|
metadata.gz.sig
CHANGED
|
Binary file
|