rspec-core 3.8.2 → 3.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f10137b78862f926840a5956452d1def7be1715745bb73edab35b73af27cd801
4
- data.tar.gz: 7d2c59eea23bd759487efb177c7e9de131a416d832ee6467b4849813d759832c
3
+ metadata.gz: 0117b5c68702f84872a6b528a286040ebad81a5201912cf75add518b16391fd8
4
+ data.tar.gz: 6a744e765c464099b304f42223079af2133ee5e278ffa3f3f3c5118f0ccdae54
5
5
  SHA512:
6
- metadata.gz: a4344a9bdf65524dc82da9368cc8d844ed1da304aa139f2a95d5a6f1c177534d95ebbf7ecd3a488c2fa65221706cf0f4afdfbfdc3d0b6846f18ffaff1b9cda17
7
- data.tar.gz: 063aee16e467179dd13d1f94a98b57fbc135d93ab9b46cf0d860903ca8a5ce130579830e6f561b288a78f642da976ac56be5ccf3ec4753d8754e2d508e650cb0
6
+ metadata.gz: d659433a8e529d32ef874d0e6c6d100a5482f1dbb1bcc00a65daccbdfd23fd16307f6938b01fada58609ea828f7215992574dd7fda7f1c2873763f9abbf77574
7
+ data.tar.gz: bdec2aae3e9a5a0c34ccba2bb97a3f4480fa8400f605bb0625b609ebb90a3abf77bfcdbe247f0137d00a2d69f26c3e9ee1565a7a653afe3d14376b3eb97f6ac4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,77 @@
1
+ ### 3.10.0 / 2020-10-30
2
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.3...v3.10.0)
3
+
4
+ Enhancements:
5
+
6
+ * Memoize `RSpec::Core::Formatters::ExceptionPresenter#exception_lines` to improve performance
7
+ with slow exception messages. (Maxime Lapointe, #2743)
8
+ * Add configuration for an error exit code (to disambiguate errored builds from failed builds
9
+ by exit status). (Dana Sherson, #2749)
10
+
11
+ # 3.9.3 / 2020-09-30
12
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.2...v3.9.3)
13
+
14
+ Bug Fixes:
15
+
16
+ * Declare `ruby2_keywords` on `method_missing` for other gems. (Jon Rowe, #2731)
17
+ * Ensure custom error codes are returned from bisect runs. (Jon Rowe, #2732)
18
+ * Ensure `RSpec::Core::Configuration` predicate config methods return booleans.
19
+ (Marc-André Lafortune, #2736)
20
+ * Prevent `rspec --bisect` from generating zombie processes while executing
21
+ bisect runs. (Benoit Tigeot, Jon Rowe, #2739)
22
+ * Predicates for pending examples, (in `RSpec::Core::Example`, `#pending?`, `#skipped?` and
23
+ `#pending_fixed?`) now return boolean values rather than truthy values.
24
+ (Marc-André Lafortune, #2756, #2758)
25
+ * Exceptions which have a message which cannot be cast to a string will no longer
26
+ cause a crash. (Jon Rowe, #2761)
27
+
28
+ ### 3.9.2 / 2020-05-02
29
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.1...v3.9.2)
30
+
31
+ Bug Fixes:
32
+
33
+ * Emit a warning when `around` hook is used with `:context` scope
34
+ (Phil Pirozhkov, #2687)
35
+ * Prevent invalid implementations of `Exception#cause` from being treated as a
36
+ valid cause (and causing strange errors) in `RSpec::Core::Formatters::ExceptionPresenter`.
37
+ (Jon Rowe, #2703)
38
+ * Correctly detect patterns when `rspec_opts` is an array in `RSpec::Core::RakeTask`.
39
+ (Marc-André Lafortune, #2704)
40
+ * Make `RSpec.clear_examples` reset example counts for example groups. This fixes
41
+ an issue with re-running specs not matching ids. (Agis Anastasopoulos, #2723)
42
+
43
+ ### 3.9.1 / 2019-12-28
44
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.0...v3.9.1)
45
+
46
+ Bug Fixes:
47
+
48
+ * Prevent bisect command from blocking when number of specs exceeds file
49
+ descriptor limit on OSX or Linux. (Benoit Tigeot, #2669)
50
+ * Prevent warnings being issued on Ruby 2.7.0. (Jon Rowe, #2680)
51
+
52
+ ### 3.9.0 / 2019-10-07
53
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.8.2...v3.9.0)
54
+
55
+ Enhancements:
56
+
57
+ * Improve the handling of errors during loading support files, if a file
58
+ errors before loading specs, RSpec will now skip loading the specs.
59
+ (David Rodríguez, #2568)
60
+ * Add support for --example-matches to run examples by regular expression.
61
+ (Sam Joseph, Matt Rider, @okothkongo1, #2586)
62
+ * Add `did_you_mean` suggestions for file names encountering a `LoadError`
63
+ outside of examples. (@obromios, #2601)
64
+ * Add a minimalist quick fix style formatter, only outputs failures as
65
+ `file:line:message`. (Romain Tartière, #2614)
66
+ * Convert string number values to integer when used for `RSpec::Configuration#fail_fast`
67
+ (Viktor Fonic, #2634)
68
+ * Issue warning when invalid values are used for `RSpec::Configuration#fail_fast`
69
+ (Viktor Fonic, #2634)
70
+ * Add support for running the Rake task in a clean environment.
71
+ (Jon Rowe, #2632)
72
+ * Indent messages by there example group / example in the documentation formatter.
73
+ (Samuel Williams, #2649)
74
+
1
75
  ### 3.8.2 / 2019-06-29
2
76
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.8.1...v3.8.2)
3
77
 
@@ -8,7 +82,7 @@ Bug Fixes:
8
82
  (Myron Marston, #2635).
9
83
 
10
84
  ### 3.8.1 / 2019-06-13
11
- [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.8.0...3.8.1)
85
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.8.0...v3.8.1)
12
86
 
13
87
  Bug Fixes:
14
88
 
@@ -2097,6 +2171,7 @@ Bug fixes
2097
2171
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v2.2.0...v2.2.1)
2098
2172
 
2099
2173
  Bug fixes
2174
+
2100
2175
  * alias_method instead of override Kernel#method_missing (John Wilger)
2101
2176
  * changed --autotest to --tty in generated command (MIKAMI Yoshiyuki)
2102
2177
  * revert change to debugger (had introduced conflict with Rails)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rspec-core [![Build Status](https://secure.travis-ci.org/rspec/rspec-core.svg?branch=master)](http://travis-ci.org/rspec/rspec-core) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.svg)](https://codeclimate.com/github/rspec/rspec-core)
1
+ # rspec-core [![Build Status](https://secure.travis-ci.org/rspec/rspec-core.svg?branch=main)](http://travis-ci.org/rspec/rspec-core) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.svg)](https://codeclimate.com/github/rspec/rspec-core)
2
2
 
3
3
  rspec-core provides the structure for writing executable examples of how your
4
4
  code should behave, and an `rspec` command with tools to constrain which
@@ -10,12 +10,12 @@ examples get run and tailor the output.
10
10
  gem install rspec-core # for rspec-core only
11
11
  rspec --help
12
12
 
13
- Want to run against the `master` branch? You'll need to include the dependent
13
+ Want to run against the `main` branch? You'll need to include the dependent
14
14
  RSpec repos as well. Add the following to your `Gemfile`:
15
15
 
16
16
  ```ruby
17
17
  %w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
18
- gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
18
+ gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'main'
19
19
  end
20
20
  ```
21
21
 
@@ -53,7 +53,7 @@ context of an _instance_ of that class.
53
53
 
54
54
  ## Nested Groups
55
55
 
56
- You can also declare nested nested groups using the `describe` or `context`
56
+ You can also declare nested groups using the `describe` or `context`
57
57
  methods:
58
58
 
59
59
  ```ruby
@@ -139,6 +139,7 @@ module RSpec
139
139
  module Core
140
140
  autoload :ExampleStatusPersister, "rspec/core/example_status_persister"
141
141
  autoload :Profiler, "rspec/core/profiler"
142
+ autoload :DidYouMean, "rspec/core/did_you_mean"
142
143
 
143
144
  # @private
144
145
  # This avoids issues with reporting time caused by examples that
@@ -6,7 +6,7 @@ module RSpec
6
6
  module Core
7
7
  module Bisect
8
8
  # A Bisect runner that runs requested subsets of the suite by forking
9
- # sub-processes. The master process bootstraps RSpec and the application
9
+ # sub-processes. The main process bootstraps RSpec and the application
10
10
  # environment (including preloading files specified via `--require`) so
11
11
  # that the individual spec runs do not have to re-pay that cost. Each
12
12
  # spec run happens in a forked process, ensuring that the spec files are
@@ -92,7 +92,11 @@ module RSpec
92
92
 
93
93
  def dispatch_specs(run_descriptor)
94
94
  pid = fork { run_specs(run_descriptor) }
95
- Process.waitpid(pid)
95
+ # We don't use Process.waitpid here as it was causing bisects to
96
+ # block due to the file descriptor limit on OSX / Linux. We need
97
+ # to detach the process to avoid having zombie processes
98
+ # consuming slots in the kernel process table during bisect runs.
99
+ Process.detach(pid)
96
100
  end
97
101
 
98
102
  private
@@ -33,7 +33,7 @@ module RSpec
33
33
 
34
34
  def start
35
35
  # Only allow remote DRb requests from this machine.
36
- DRb.install_acl ACL.new(%w[ deny all allow localhost allow 127.0.0.1 ])
36
+ DRb.install_acl ACL.new(%w[ deny all allow localhost allow 127.0.0.1 allow ::1 ])
37
37
 
38
38
  # We pass `nil` as the first arg to allow it to pick a DRb port.
39
39
  @drb = DRb.start_service(nil, self)
@@ -67,15 +67,17 @@ module RSpec
67
67
  end
68
68
 
69
69
  # @private
70
- def self.define_aliases(name, alias_name)
70
+ def self.define_alias(name, alias_name)
71
71
  alias_method alias_name, name
72
72
  alias_method "#{alias_name}=", "#{name}="
73
- define_predicate_for alias_name
73
+ define_predicate alias_name
74
74
  end
75
75
 
76
76
  # @private
77
- def self.define_predicate_for(*names)
78
- names.each { |name| alias_method "#{name}?", name }
77
+ def self.define_predicate(name)
78
+ define_method "#{name}?" do
79
+ !!send(name)
80
+ end
79
81
  end
80
82
 
81
83
  # @private
@@ -88,7 +90,7 @@ module RSpec
88
90
  add_read_only_setting name
89
91
 
90
92
  Array(opts[:alias_with]).each do |alias_name|
91
- define_aliases(name, alias_name)
93
+ define_alias(name, alias_name)
92
94
  end
93
95
  end
94
96
 
@@ -98,7 +100,7 @@ module RSpec
98
100
  def self.add_read_only_setting(name, opts={})
99
101
  raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
100
102
  define_reader name
101
- define_predicate_for name
103
+ define_predicate name
102
104
  end
103
105
 
104
106
  # @macro [attach] add_setting
@@ -202,10 +204,33 @@ module RSpec
202
204
  only_failures? && !example_status_persistence_file_path
203
205
  end
204
206
 
205
- # @macro add_setting
207
+ # @macro define_reader
206
208
  # If specified, indicates the number of failures required before cleaning
207
- # up and exit (default: `nil`).
208
- add_setting :fail_fast
209
+ # up and exit (default: `nil`). Can also be `true` to fail and exit on first
210
+ # failure
211
+ define_reader :fail_fast
212
+
213
+ # @see fail_fast
214
+ def fail_fast=(value)
215
+ case value
216
+ when true, 'true'
217
+ @fail_fast = true
218
+ when false, 'false', 0
219
+ @fail_fast = false
220
+ when nil
221
+ @fail_fast = nil
222
+ else
223
+ @fail_fast = value.to_i
224
+
225
+ if value.to_i == 0
226
+ # TODO: in RSpec 4, consider raising an error here.
227
+ RSpec.warning "Cannot set `RSpec.configuration.fail_fast`" \
228
+ " to `#{value.inspect}`. Only `true`, `false`, `nil` and integers" \
229
+ " are valid values."
230
+ @fail_fast = true
231
+ end
232
+ end
233
+ end
209
234
 
210
235
  # @macro add_setting
211
236
  # Prints the formatter output of your suite without running any
@@ -217,6 +242,11 @@ module RSpec
217
242
  # @return [Integer]
218
243
  add_setting :failure_exit_code
219
244
 
245
+ # @macro add_setting
246
+ # The exit code to return if there are any errors outside examples (default: failure_exit_code)
247
+ # @return [Integer]
248
+ add_setting :error_exit_code
249
+
220
250
  # @macro add_setting
221
251
  # Whether or not to fail when there are no RSpec examples (default: false).
222
252
  # @return [Boolean]
@@ -289,7 +319,8 @@ module RSpec
289
319
  # Report the times for the slowest examples (default: `false`).
290
320
  # Use this to specify the number of examples to include in the profile.
291
321
  # @return [Boolean]
292
- add_setting :profile_examples
322
+ attr_writer :profile_examples
323
+ define_predicate :profile_examples
293
324
 
294
325
  # @macro add_setting
295
326
  # Run all examples if none match the configured filters
@@ -497,6 +528,7 @@ module RSpec
497
528
  @pattern = '**{,/*/**}/*_spec.rb'
498
529
  @exclude_pattern = ''
499
530
  @failure_exit_code = 1
531
+ @error_exit_code = nil # so it can be overridden by failure exit code
500
532
  @fail_if_no_examples = false
501
533
  @spec_files_loaded = false
502
534
 
@@ -1106,7 +1138,7 @@ module RSpec
1106
1138
  #
1107
1139
  # # This lets you do this:
1108
1140
  #
1109
- # describe Thing do
1141
+ # RSpec.describe Thing do
1110
1142
  # pending "does something" do
1111
1143
  # thing = Thing.new
1112
1144
  # end
@@ -1114,7 +1146,7 @@ module RSpec
1114
1146
  #
1115
1147
  # # ... which is the equivalent of
1116
1148
  #
1117
- # describe Thing do
1149
+ # RSpec.describe Thing do
1118
1150
  # it "does something", :pending => true do
1119
1151
  # thing = Thing.new
1120
1152
  # end
@@ -1167,7 +1199,7 @@ module RSpec
1167
1199
  #
1168
1200
  # # allows the user to include a shared example group like:
1169
1201
  #
1170
- # describe Entity do
1202
+ # RSpec.describe Entity do
1171
1203
  # it_has_behavior 'sortability' do
1172
1204
  # let(:sortable) { Entity.new }
1173
1205
  # end
@@ -1327,6 +1359,12 @@ module RSpec
1327
1359
  # end
1328
1360
  # end
1329
1361
  #
1362
+ # module PreferencesHelpers
1363
+ # def preferences(user, preferences = {})
1364
+ # # ...
1365
+ # end
1366
+ # end
1367
+ #
1330
1368
  # module UserHelpers
1331
1369
  # def users(username)
1332
1370
  # # ...
@@ -1335,12 +1373,17 @@ module RSpec
1335
1373
  #
1336
1374
  # RSpec.configure do |config|
1337
1375
  # config.include(UserHelpers) # included in all groups
1376
+ #
1377
+ # # included in examples with `:preferences` metadata
1378
+ # config.include(PreferenceHelpers, :preferences)
1379
+ #
1380
+ # # included in examples with `:type => :request` metadata
1338
1381
  # config.include(AuthenticationHelpers, :type => :request)
1339
1382
  # end
1340
1383
  #
1341
- # describe "edit profile", :type => :request do
1384
+ # describe "edit profile", :preferences, :type => :request do
1342
1385
  # it "can be viewed by owning user" do
1343
- # login_as users(:jdoe)
1386
+ # login_as preferences(users(:jdoe), :lang => 'es')
1344
1387
  # get "/profiles/jdoe"
1345
1388
  # assert_select ".username", :text => 'jdoe'
1346
1389
  # end
@@ -1368,17 +1411,21 @@ module RSpec
1368
1411
  #
1369
1412
  # @example
1370
1413
  #
1371
- # RSpec.shared_context "example users" do
1414
+ # RSpec.shared_context "example admin user" do
1372
1415
  # let(:admin_user) { create_user(:admin) }
1416
+ # end
1417
+ #
1418
+ # RSpec.shared_context "example guest user" do
1373
1419
  # let(:guest_user) { create_user(:guest) }
1374
1420
  # end
1375
1421
  #
1376
1422
  # RSpec.configure do |config|
1377
- # config.include_context "example users", :type => :request
1423
+ # config.include_context "example guest user", :type => :request
1424
+ # config.include_context "example admin user", :admin, :type => :request
1378
1425
  # end
1379
1426
  #
1380
1427
  # RSpec.describe "The admin page", :type => :request do
1381
- # it "can be viewed by admins" do
1428
+ # it "can be viewed by admins", :admin do
1382
1429
  # login_with admin_user
1383
1430
  # get "/admin"
1384
1431
  # expect(response).to be_ok
@@ -1420,12 +1467,20 @@ module RSpec
1420
1467
  # end
1421
1468
  # end
1422
1469
  #
1470
+ # module PermissionHelpers
1471
+ # def define_permissions
1472
+ # # ...
1473
+ # end
1474
+ # end
1475
+ #
1423
1476
  # RSpec.configure do |config|
1424
1477
  # config.extend(UiHelpers, :type => :request)
1478
+ # config.extend(PermissionHelpers, :with_permissions, :type => :request)
1425
1479
  # end
1426
1480
  #
1427
- # describe "edit profile", :type => :request do
1481
+ # describe "edit profile", :with_permissions, :type => :request do
1428
1482
  # run_in_browser
1483
+ # define_permissions
1429
1484
  #
1430
1485
  # it "does stuff in the client" do
1431
1486
  # # ...
@@ -1718,7 +1773,7 @@ module RSpec
1718
1773
  # rspec.expose_current_running_example_as :example
1719
1774
  # end
1720
1775
  #
1721
- # describe MyClass do
1776
+ # RSpec.describe MyClass do
1722
1777
  # before do
1723
1778
  # # `example` can be used here because of the above config.
1724
1779
  # do_something if example.metadata[:type] == "foo"
@@ -1883,7 +1938,8 @@ module RSpec
1883
1938
  #
1884
1939
  # This method differs from {Hooks#before} in only one way: it supports
1885
1940
  # the `:suite` scope. Hooks with the `:suite` scope will be run once before
1886
- # the first example of the entire suite is executed.
1941
+ # the first example of the entire suite is executed. Conditions passed along
1942
+ # with `:suite` are effectively ignored.
1887
1943
  #
1888
1944
  # @see #prepend_before
1889
1945
  # @see #after
@@ -1912,7 +1968,8 @@ module RSpec
1912
1968
  #
1913
1969
  # This method differs from {Hooks#prepend_before} in only one way: it supports
1914
1970
  # the `:suite` scope. Hooks with the `:suite` scope will be run once before
1915
- # the first example of the entire suite is executed.
1971
+ # the first example of the entire suite is executed. Conditions passed along
1972
+ # with `:suite` are effectively ignored.
1916
1973
  #
1917
1974
  # @see #before
1918
1975
  # @see #after
@@ -1936,7 +1993,8 @@ module RSpec
1936
1993
  #
1937
1994
  # This method differs from {Hooks#after} in only one way: it supports
1938
1995
  # the `:suite` scope. Hooks with the `:suite` scope will be run once after
1939
- # the last example of the entire suite is executed.
1996
+ # the last example of the entire suite is executed. Conditions passed along
1997
+ # with `:suite` are effectively ignored.
1940
1998
  #
1941
1999
  # @see #append_after
1942
2000
  # @see #before
@@ -1965,7 +2023,8 @@ module RSpec
1965
2023
  #
1966
2024
  # This method differs from {Hooks#append_after} in only one way: it supports
1967
2025
  # the `:suite` scope. Hooks with the `:suite` scope will be run once after
1968
- # the last example of the entire suite is executed.
2026
+ # the last example of the entire suite is executed. Conditions passed along
2027
+ # with `:suite` are effectively ignored.
1969
2028
  #
1970
2029
  # @see #append_after
1971
2030
  # @see #before
@@ -2051,6 +2110,11 @@ module RSpec
2051
2110
 
2052
2111
  def load_file_handling_errors(method, file)
2053
2112
  __send__(method, file)
2113
+ rescue LoadError => ex
2114
+ relative_file = Metadata.relative_path(file)
2115
+ suggestions = DidYouMean.new(relative_file).call
2116
+ reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.#{suggestions}")
2117
+ RSpec.world.wants_to_quit = true
2054
2118
  rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
2055
2119
  relative_file = Metadata.relative_path(file)
2056
2120
  reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.")
@@ -0,0 +1,46 @@
1
+ module RSpec
2
+ module Core
3
+ # @private
4
+ # Wrapper around Ruby's `DidYouMean::SpellChecker` when available to provide file name suggestions.
5
+ class DidYouMean
6
+ attr_reader :relative_file_name
7
+
8
+ def initialize(relative_file_name)
9
+ @relative_file_name = relative_file_name
10
+ end
11
+
12
+ if defined?(::DidYouMean::SpellChecker)
13
+ # provide probable suggestions
14
+ def call
15
+ checker = ::DidYouMean::SpellChecker.new(:dictionary => Dir["spec/**/*.rb"])
16
+ probables = checker.correct(relative_file_name.sub('./', ''))[0..2]
17
+ return '' unless probables.any?
18
+
19
+ formats probables
20
+ end
21
+ else
22
+ # return a hint if API for ::DidYouMean::SpellChecker not supported
23
+ def call
24
+ "\nHint: Install the `did_you_mean` gem in order to provide suggestions for similarly named files."
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def formats(probables)
31
+ rspec_format = probables.map { |s, _| "rspec ./#{s}" }
32
+ red_font(top_and_tail rspec_format)
33
+ end
34
+
35
+ def top_and_tail(rspec_format)
36
+ spaces = ' ' * 20
37
+ rspec_format.insert(0, ' - Did you mean?').join("\n#{spaces}") + "\n"
38
+ end
39
+
40
+ def red_font(mytext)
41
+ colorizer = ::RSpec::Core::Formatters::ConsoleCodes
42
+ colorizer.wrap mytext, :failure
43
+ end
44
+ end
45
+ end
46
+ end