rspec-support 3.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +269 -0
  5. data/LICENSE.md +23 -0
  6. data/README.md +40 -0
  7. data/lib/rspec/support.rb +149 -0
  8. data/lib/rspec/support/caller_filter.rb +83 -0
  9. data/lib/rspec/support/comparable_version.rb +46 -0
  10. data/lib/rspec/support/differ.rb +215 -0
  11. data/lib/rspec/support/directory_maker.rb +63 -0
  12. data/lib/rspec/support/encoded_string.rb +165 -0
  13. data/lib/rspec/support/fuzzy_matcher.rb +48 -0
  14. data/lib/rspec/support/hunk_generator.rb +47 -0
  15. data/lib/rspec/support/matcher_definition.rb +42 -0
  16. data/lib/rspec/support/method_signature_verifier.rb +438 -0
  17. data/lib/rspec/support/mutex.rb +73 -0
  18. data/lib/rspec/support/object_formatter.rb +275 -0
  19. data/lib/rspec/support/recursive_const_methods.rb +76 -0
  20. data/lib/rspec/support/reentrant_mutex.rb +53 -0
  21. data/lib/rspec/support/ruby_features.rb +176 -0
  22. data/lib/rspec/support/source.rb +75 -0
  23. data/lib/rspec/support/source/location.rb +21 -0
  24. data/lib/rspec/support/source/node.rb +110 -0
  25. data/lib/rspec/support/source/token.rb +87 -0
  26. data/lib/rspec/support/spec.rb +81 -0
  27. data/lib/rspec/support/spec/deprecation_helpers.rb +64 -0
  28. data/lib/rspec/support/spec/formatting_support.rb +9 -0
  29. data/lib/rspec/support/spec/in_sub_process.rb +69 -0
  30. data/lib/rspec/support/spec/library_wide_checks.rb +150 -0
  31. data/lib/rspec/support/spec/shell_out.rb +89 -0
  32. data/lib/rspec/support/spec/stderr_splitter.rb +63 -0
  33. data/lib/rspec/support/spec/string_matcher.rb +46 -0
  34. data/lib/rspec/support/spec/with_isolated_directory.rb +13 -0
  35. data/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
  36. data/lib/rspec/support/version.rb +7 -0
  37. data/lib/rspec/support/warnings.rb +39 -0
  38. metadata +150 -0
  39. metadata.gz.sig +0 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a5535fbba324eec41454922efc4e7b5e1c52e499c781b94879d3c5c5e5aa260b
4
+ data.tar.gz: 1fcf50869244a4f7d8eba9a55d8f1fc1dfc5a0214bc75b763e325a871539ad96
5
+ SHA512:
6
+ metadata.gz: a95932acac40aa6830dd7040181475816f80176a3fc218da203b53c1b63455a25a5ed3d72a282a50cbfcc314c8ef43f3496673049b4507f864d2c894618d684c
7
+ data.tar.gz: 9c8a21433d0a8af543249d354aa129e16589a238d0ccea7aec26dcce3c0d399fb158226639c6955eacc3b5fe8ef00fffa277ba8c922073d2f7f1ee8f170e5311
@@ -0,0 +1 @@
1
+ $u�ST��M�]Z�o�������S���4��v���f{ɞ�:�i��t�����&C\f�� =&?H�ű�6�G_����RU&�?X�'F+0�-����zl茽!�Yr R��q뻎�y��g�Z� ���s+q̵���%����S�qh2㠮�%F<v��� <�彇����.������5m�f����� ��� �5q�� 'c;����%{�y�k�{�Z[�W<;[�l�&T��}]�>�2���v���sZ��jU$-�z������'h�z�a��|�4z�Wͱǩ}�)Íq�'�&<��O{��2ca�1}fƻ�NT6�>�P�U��{�t=_9}��ӯ����\���g�{R����
Binary file
@@ -0,0 +1,269 @@
1
+ ### 3.8.3 / 2019-10-02
2
+
3
+ Bug Fixes:
4
+
5
+ * Escape \r when outputting strings inside arrays.
6
+ (Tomita Masahiro, Jon Rowe, #378)
7
+ * Ensure that optional hash arguments are recognised correctly vs keyword
8
+ arguments. (Evgeni Dzhelyov, #366)
9
+
10
+ ### 3.8.2 / 2019-06-10
11
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.1...v3.8.2)
12
+
13
+ Bug Fixes:
14
+
15
+ * Ensure that an empty hash is recognised as empty keyword arguments when
16
+ applicable. (Thomas Walpole, #375)
17
+ * Ensure that diffing truthy values produce diffs consistently.
18
+ (Lucas Nestor, #377)
19
+
20
+ ### 3.8.1 / 2019-03-03
21
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...v3.8.1)
22
+
23
+ Bug Fixes:
24
+
25
+ * Ensure that inspecting a `SimpleDelegator` based object works regardless of
26
+ visibilty of the `__getobj__` method. (Jon Rowe, #369)
27
+
28
+ ### 3.8.0 / 2018-08-04
29
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0)
30
+
31
+ Bug Fixes:
32
+
33
+ * Order hash keys before diffing to improve diff accuracy when using mocked calls.
34
+ (James Crisp, #334)
35
+
36
+ ### 3.7.1 / 2018-01-29
37
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.0...v3.7.1)
38
+
39
+ Bug Fixes:
40
+
41
+ * Fix source extraction logic so that it does not trigger a `SystemStackError`
42
+ when processing deeply nested example groups. (Craig Bass, #343)
43
+
44
+ ### 3.7.0 / 2017-10-17
45
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.6.0...v3.7.0)
46
+
47
+ Enhancements:
48
+
49
+ * Improve compatibility with `--enable-frozen-string-literal` option
50
+ on Ruby 2.3+. (Pat Allan, #320)
51
+ * Add `Support.class_of` for extracting class of any object.
52
+ (Yuji Nakayama, #325)
53
+
54
+ Bug Fixes:
55
+
56
+ * Fix recursive const support to not blow up when given buggy classes
57
+ that raise odd errors from `#to_str`. (Myron Marston, #317)
58
+
59
+ ### 3.6.0 / 2017-05-04
60
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.6.0.beta2...3.6.0)
61
+
62
+ Enhancements:
63
+
64
+ * Import `Source` classes from rspec-core. (Yuji Nakayama, #315)
65
+
66
+ ### 3.6.0.beta2 / 2016-12-12
67
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.6.0.beta1...v3.6.0.beta2)
68
+
69
+ No user-facing changes.
70
+
71
+ ### 3.6.0.beta1 / 2016-10-09
72
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0...v3.6.0.beta1)
73
+
74
+ Bug Fixes:
75
+
76
+ * Prevent truncated formatted object output from mangling console codes. (#294, Anson Kelly)
77
+
78
+ ### 3.5.0 / 2016-07-01
79
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta4...v3.5.0)
80
+
81
+ **No user facing changes since beta4**
82
+
83
+ ### 3.5.0.beta4 / 2016-06-05
84
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta3...v3.5.0.beta4)
85
+
86
+ Enhancements:
87
+ * Improve `MethodSignature` to better support keyword arguments. (#250, Rob Smith).
88
+
89
+ ### 3.5.0.beta3 / 2016-04-02
90
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta2...v3.5.0.beta3)
91
+
92
+ Bug Fixes:
93
+
94
+ * Fix `EncodedString` to properly handle the behavior of `String#split`
95
+ on JRuby when the string contains invalid bytes. (Jon Rowe, #268)
96
+ * Fix `ObjectFormatter` so that formatting objects that don't respond to
97
+ `#inspect` (such as `BasicObject`) does not cause `NoMethodError`.
98
+ (Yuji Nakayama, #269)
99
+ * Fix `ObjectFormatter` so that formatting recursive array or hash does not
100
+ cause `SystemStackError`. (Yuji Nakayama, #270, #272)
101
+
102
+ ### 3.5.0.beta2 / 2016-03-10
103
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta1...v3.5.0.beta2)
104
+
105
+ No user-facing changes.
106
+
107
+ ### 3.5.0.beta1 / 2016-02-06
108
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.4.1...v3.5.0.beta1)
109
+
110
+ Enhancements:
111
+
112
+ * Improve formatting of objects by allowing truncation to a pre-configured length.
113
+ (Liam M, #256)
114
+
115
+ ### 3.4.1 / 2015-11-20
116
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.4.0...v3.4.1)
117
+
118
+ Bug Fixes:
119
+
120
+ * Fix `RSpec::Support::RubyFeature.ripper_supported?` so it returns
121
+ `false` on Rubinius since the Rubinius team has no plans to support
122
+ it. This prevents rspec-core from trying to load and use ripper to
123
+ extract failure snippets. (Aaron Stone, #251)
124
+
125
+ Changes:
126
+
127
+ * Remove `VersionChecker` in favor of `ComparableVersion`. (Yuji Nakayama, #266)
128
+
129
+ ### 3.4.0 / 2015-11-11
130
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.3.0...v3.4.0)
131
+
132
+ Enhancements:
133
+
134
+ * Improve formatting of `Delegator` based objects (e.g. `SimpleDelgator`) in
135
+ failure messages and diffs. (Andrew Horner, #215)
136
+ * Add `ComparableVersion`. (Yuji Nakayama, #245)
137
+ * Add `Ripper` support detection. (Yuji Nakayama, #245)
138
+
139
+ Bug Fixes:
140
+
141
+ * Work around bug in JRuby that reports that `attr_writer` methods
142
+ have no parameters, causing RSpec's verifying doubles to wrongly
143
+ fail when mocking or stubbing a writer method on JRuby. (Myron Marston, #225)
144
+
145
+ ### 3.3.0 / 2015-06-12
146
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.2.2...v3.3.0)
147
+
148
+ Enhancements:
149
+
150
+ * Improve formatting of arrays and hashes in failure messages so they
151
+ use our custom formatting of matchers, time objects, etc.
152
+ (Myron Marston, Nicholas Chmielewski, #205)
153
+ * Use improved formatting for diffs as well. (Nicholas Chmielewski, #205)
154
+
155
+ Bug Fixes:
156
+
157
+ * Fix `FuzzyMatcher` so that it checks `expected == actual` rather than
158
+ `actual == expected`, which avoids errors in situations where the
159
+ `actual` object's `==` is improperly implemented to assume that only
160
+ objects of the same type will be given. This allows rspec-mocks'
161
+ `anything` to match against objects with buggy `==` definitions.
162
+ (Myron Marston, #193)
163
+
164
+ ### 3.2.2 / 2015-02-23
165
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.2.1...v3.2.2)
166
+
167
+ Bug Fixes:
168
+
169
+ * Fix an encoding issue with `EncodedString#split` when encountering an
170
+ invalid byte string. (Benjamin Fleischer, #1760)
171
+
172
+ ### 3.2.1 / 2015-02-04
173
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.2.0...v3.2.1)
174
+
175
+ Bug Fixes:
176
+
177
+ * Fix `RSpec::CallerFilter` to work on Rubinius 2.2.
178
+ (Myron Marston, #169)
179
+
180
+ ### 3.2.0 / 2015-02-03
181
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.1.2...v3.2.0)
182
+
183
+ Enhancements:
184
+
185
+ * Add extra Ruby type detection. (Jon Rowe, #133)
186
+ * Make differ instance re-usable. (Alexey Fedorov, #160)
187
+
188
+ Bug Fixes:
189
+
190
+ * Do not consider `[]` and `{}` to match when performing fuzzy matching.
191
+ (Myron Marston, #157)
192
+
193
+ ### 3.1.2 / 2014-10-08
194
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.1.1...v3.1.2)
195
+
196
+ Bug Fixes:
197
+
198
+ * Fix method signature to not blow up with a `NoMethodError` on 1.8.7 when
199
+ verifying against an RSpec matcher. (Myron Marston, #116)
200
+
201
+ ### 3.1.1 / 2014-09-26
202
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.1.0...v3.1.1)
203
+
204
+ Bug Fixes:
205
+
206
+ * Fix `RSpec::Support::DirectoryMaker` (used by `rspec --init` and
207
+ `rails generate rspec:install`) so that it detects absolute paths
208
+ on Windows properly. (Scott Archer, #107, #108, #109) (Jon Rowe, #110)
209
+
210
+ ### 3.1.0 / 2014-09-04
211
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.4...v3.1.0)
212
+
213
+ Bug Fixes:
214
+
215
+ * Fix `FuzzyMatcher` so that it does not wrongly match a struct against
216
+ an array. (Myron Marston, #97)
217
+ * Prevent infinitely recursing `#flatten` methods from causing the differ
218
+ to hang. (Jon Rowe, #101)
219
+
220
+ ### 3.0.4 / 2014-08-14
221
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.3...v3.0.4)
222
+
223
+ Bug Fixes:
224
+
225
+ * Fix `FuzzyMatcher` so that it does not silence `ArgumentError` raised
226
+ from broken implementations of `==`. (Myron Marston, #94)
227
+
228
+ ### 3.0.3 / 2014-07-21
229
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.2...v3.0.3)
230
+
231
+ Bug Fixes:
232
+
233
+ * Fix regression in `Support#method_handle_for` where proxy objects
234
+ with method delegated would wrongly not return a method handle.
235
+ (Jon Rowe, #90)
236
+ * Properly detect Module#prepend support in Ruby 2.1+ (Ben Langfeld, #91)
237
+ * Fix `rspec/support/warnings.rb` so it can be loaded and used in
238
+ isolation. (Myron Marston, #93)
239
+
240
+ ### 3.0.2 / 2014-06-20
241
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.1...v3.0.2)
242
+
243
+ * Revert `BlockSignature` change from 3.0.1 because of a ruby bug that
244
+ caused it to change the block's behavior (https://bugs.ruby-lang.org/issues/9967).
245
+ (Myron Marston, rspec-mocks#721)
246
+
247
+ ### 3.0.1 / 2014-06-19
248
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.0...v3.0.1)
249
+
250
+ * Fix `BlockSignature` so that it correctly differentiates between
251
+ required and optional block args. (Myron Marston, rspec-mocks#714)
252
+
253
+ ### 3.0.0 / 2014-06-01
254
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.0.rc1...v3.0.0)
255
+
256
+ ### 3.0.0.rc1 / 2014-05-18
257
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.0.beta2...v3.0.0.rc1)
258
+
259
+ ### 3.0.0.beta2 / 2014-02-17
260
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.0.beta1...v3.0.0.beta2)
261
+
262
+ Bug Fixes:
263
+
264
+ * Issue message when :replacement is passed to `RSpec.warn_with`. (Jon Rowe)
265
+
266
+ ### 3.0.0.beta1 / 2013-11-07
267
+ [Full Changelog](https://github.com/rspec/rspec-support/compare/0dc12d1bdbbacc757a9989f8c09cd08ef3a4837e...v3.0.0.beta1)
268
+
269
+ Initial release.
@@ -0,0 +1,23 @@
1
+ The MIT License (MIT)
2
+ ====================
3
+
4
+ * Copyright © 2013 David Chelimsky, Myron Marston, Jon Rowe, Sam Phippen, Xavier Shay, Bradley Schaefer
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # RSpec::Support
2
+
3
+ `RSpec::Support` provides common functionality to `RSpec::Core`,
4
+ `RSpec::Expectations` and `RSpec::Mocks`. It is considered
5
+ suitable for internal use only at this time.
6
+
7
+ ## Installation / Usage
8
+
9
+ Install one or more of the `RSpec` gems.
10
+
11
+ Want to run against the `master` branch? You'll need to include the dependent
12
+ RSpec repos as well. Add the following to your `Gemfile`:
13
+
14
+ ```ruby
15
+ %w[rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
16
+ gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
17
+ end
18
+ ```
19
+
20
+ ## Contributing
21
+
22
+ Once you've set up the environment, you'll need to cd into the working
23
+ directory of whichever repo you want to work in. From there you can run the
24
+ specs and cucumber features, and make patches.
25
+
26
+ NOTE: You do not need to use rspec-dev to work on a specific RSpec repo. You
27
+ can treat each RSpec repo as an independent project.
28
+
29
+ - [Build details](BUILD_DETAIL.md)
30
+ - [Code of Conduct](CODE_OF_CONDUCT.md)
31
+ - [Detailed contributing guide](CONTRIBUTING.md)
32
+ - [Development setup guide](DEVELOPMENT.md)
33
+
34
+ ## Patches
35
+
36
+ Please submit a pull request or a github issue. If you submit an issue, please
37
+ include a link to either of:
38
+
39
+ * a gist (or equivalent) of the patch
40
+ * a branch or commit in your github fork of the repo
@@ -0,0 +1,149 @@
1
+ module RSpec
2
+ module Support
3
+ # @api private
4
+ #
5
+ # Defines a helper method that is optimized to require files from the
6
+ # named lib. The passed block MUST be `{ |f| require_relative f }`
7
+ # because for `require_relative` to work properly from within the named
8
+ # lib the line of code must be IN that lib.
9
+ #
10
+ # `require_relative` is preferred when available because it is always O(1),
11
+ # regardless of the number of dirs in $LOAD_PATH. `require`, on the other
12
+ # hand, does a linear O(N) search over the dirs in the $LOAD_PATH until
13
+ # it can resolve the file relative to one of the dirs.
14
+ def self.define_optimized_require_for_rspec(lib, &require_relative)
15
+ name = "require_rspec_#{lib}"
16
+
17
+ if Kernel.respond_to?(:require_relative)
18
+ (class << self; self; end).__send__(:define_method, name) do |f|
19
+ require_relative.call("#{lib}/#{f}")
20
+ end
21
+ else
22
+ (class << self; self; end).__send__(:define_method, name) do |f|
23
+ require "rspec/#{lib}/#{f}"
24
+ end
25
+ end
26
+ end
27
+
28
+ define_optimized_require_for_rspec(:support) { |f| require_relative(f) }
29
+ require_rspec_support "version"
30
+ require_rspec_support "ruby_features"
31
+
32
+ # @api private
33
+ KERNEL_METHOD_METHOD = ::Kernel.instance_method(:method)
34
+
35
+ # @api private
36
+ #
37
+ # Used internally to get a method handle for a particular object
38
+ # and method name.
39
+ #
40
+ # Includes handling for a few special cases:
41
+ #
42
+ # - Objects that redefine #method (e.g. an HTTPRequest struct)
43
+ # - BasicObject subclasses that mixin a Kernel dup (e.g. SimpleDelegator)
44
+ # - Objects that undefine method and delegate everything to another
45
+ # object (e.g. Mongoid association objects)
46
+ if RubyFeatures.supports_rebinding_module_methods?
47
+ def self.method_handle_for(object, method_name)
48
+ KERNEL_METHOD_METHOD.bind(object).call(method_name)
49
+ rescue NameError => original
50
+ begin
51
+ handle = object.method(method_name)
52
+ raise original unless handle.is_a? Method
53
+ handle
54
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue
55
+ raise original
56
+ end
57
+ end
58
+ else
59
+ def self.method_handle_for(object, method_name)
60
+ if ::Kernel === object
61
+ KERNEL_METHOD_METHOD.bind(object).call(method_name)
62
+ else
63
+ object.method(method_name)
64
+ end
65
+ rescue NameError => original
66
+ begin
67
+ handle = object.method(method_name)
68
+ raise original unless handle.is_a? Method
69
+ handle
70
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue
71
+ raise original
72
+ end
73
+ end
74
+ end
75
+
76
+ # @api private
77
+ #
78
+ # Used internally to get a class of a given object, even if it does not respond to #class.
79
+ def self.class_of(object)
80
+ object.class
81
+ rescue NoMethodError
82
+ singleton_class = class << object; self; end
83
+ singleton_class.ancestors.find { |ancestor| !ancestor.equal?(singleton_class) }
84
+ end
85
+
86
+ # A single thread local variable so we don't excessively pollute that namespace.
87
+ def self.thread_local_data
88
+ Thread.current[:__rspec] ||= {}
89
+ end
90
+
91
+ # @api private
92
+ def self.failure_notifier=(callable)
93
+ thread_local_data[:failure_notifier] = callable
94
+ end
95
+
96
+ # @private
97
+ DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
98
+
99
+ # @api private
100
+ def self.failure_notifier
101
+ thread_local_data[:failure_notifier] || DEFAULT_FAILURE_NOTIFIER
102
+ end
103
+
104
+ # @api private
105
+ def self.notify_failure(failure, options={})
106
+ failure_notifier.call(failure, options)
107
+ end
108
+
109
+ # @api private
110
+ def self.with_failure_notifier(callable)
111
+ orig_notifier = failure_notifier
112
+ self.failure_notifier = callable
113
+ yield
114
+ ensure
115
+ self.failure_notifier = orig_notifier
116
+ end
117
+
118
+ class << self
119
+ # @api private
120
+ attr_writer :warning_notifier
121
+ end
122
+
123
+ # @private
124
+ DEFAULT_WARNING_NOTIFIER = lambda { |warning| ::Kernel.warn warning }
125
+
126
+ # @api private
127
+ def self.warning_notifier
128
+ @warning_notifier ||= DEFAULT_WARNING_NOTIFIER
129
+ end
130
+
131
+ # @private
132
+ module AllExceptionsExceptOnesWeMustNotRescue
133
+ # These exceptions are dangerous to rescue as rescuing them
134
+ # would interfere with things we should not interfere with.
135
+ AVOID_RESCUING = [NoMemoryError, SignalException, Interrupt, SystemExit]
136
+
137
+ def self.===(exception)
138
+ AVOID_RESCUING.none? { |ar| ar === exception }
139
+ end
140
+ end
141
+
142
+ # The Differ is only needed when a spec fails with a diffable failure.
143
+ # In the more common case of all specs passing or the only failures being
144
+ # non-diffable, we can avoid the extra cost of loading the differ, diff-lcs,
145
+ # pp, etc by avoiding an unnecessary require. Instead, autoload will take
146
+ # care of loading the differ on first use.
147
+ autoload :Differ, "rspec/support/differ"
148
+ end
149
+ end