rspec-core 3.8.1 → 3.9.3

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: 2e83f32ce194b3903060d4338a0dd48d533c2322a91c2c50cf4a4c6b34b6ca48
4
- data.tar.gz: c63129c5d7bbc1bdfa955772aac6f5a2aff7a1b925bda15ea1099b608cf6aef2
3
+ metadata.gz: 30e931022769b69911776a8c64de53481785df0074e84693b5e4031c20a53bb2
4
+ data.tar.gz: 9d5f23168383bff0e8f3152d9e111ed7600ee1cefb9ccaeb6c1a0fa384dfe3b1
5
5
  SHA512:
6
- metadata.gz: 5530f82ce2eb36ddd2b0b6c4fb062b1538fdb6615fe18d43ca7b959bda00b5c80331020dfcbe808d3e2c5352ad4cd3bd496792951fb1d600c2fcf7f7b1cf6e9b
7
- data.tar.gz: 526bcd7bf5a7f85afa55559ea99fc4d9ff0811a5b1547a586dacfa584f4ecf74288a691f1968b262ae0fc47c2b89b2d6a90ef1a4a2549ee2c01cc54e40716d74
6
+ metadata.gz: 50a9d24a978ca5c0e13bccb4b10343aeac24d2895692d0a2c7d3a6ab429213ede9b9406d4deca6d7cb496f91919eb38fe711ca0294eb94d26e60e4c07abb2e4b
7
+ data.tar.gz: e412bad1efb696f88065ba2adab372ef8e613ece6f70dd8bf193daeab5e3c8ea41978d3d2b3f5829c4a11c3eb3e2f01428f979d8b75f1f658dc4dcb78fdbf263
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,5 +1,78 @@
1
+ # 3.9.3 / 2020-09-30
2
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.2...v3.9.3)
3
+
4
+ Bug Fixes:
5
+
6
+ * Declare `ruby2_keywords` on `method_missing` for other gems. (Jon Rowe, #2731)
7
+ * Ensure custom error codes are returned from bisect runs. (Jon Rowe, #2732)
8
+ * Ensure `RSpec::Core::Configuration` predicate config methods return booleans.
9
+ (Marc-André Lafortune, #2736)
10
+ * Prevent `rspec --bisect` from generating zombie processes while executing
11
+ bisect runs. (Benoit Tigeot, Jon Rowe, #2739)
12
+ * Predicates for pending examples, (in `RSpec::Core::Example`, `#pending?`, `#skipped?` and
13
+ `#pending_fixed?`) now return boolean values rather than truthy values.
14
+ (Marc-André Lafortune, #2756, #2758)
15
+ * Exceptions which have a message which cannot be cast to a string will no longer
16
+ cause a crash. (Jon Rowe, #2761)
17
+
18
+ ### 3.9.2 / 2020-05-02
19
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.1...v3.9.2)
20
+
21
+ Bug Fixes:
22
+
23
+ * Emit a warning when `around` hook is used with `:context` scope
24
+ (Phil Pirozhkov, #2687)
25
+ * Prevent invalid implementations of `Exception#cause` from being treated as a
26
+ valid cause (and causing strange errors) in `RSpec::Core::Formatters::ExceptionPresenter`.
27
+ (Jon Rowe, #2703)
28
+ * Correctly detect patterns when `rspec_opts` is an array in `RSpec::Core::RakeTask`.
29
+ (Marc-André Lafortune, #2704)
30
+ * Make `RSpec.clear_examples` reset example counts for example groups. This fixes
31
+ an issue with re-running specs not matching ids. (Agis Anastasopoulos, #2723)
32
+
33
+ ### 3.9.1 / 2019-12-28
34
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.0...v3.9.1)
35
+
36
+ Bug Fixes:
37
+
38
+ * Prevent bisect command from blocking when number of specs exceeds file
39
+ descriptor limit on OSX or Linux. (Benoit Tigeot, #2669)
40
+ * Prevent warnings being issued on Ruby 2.7.0. (Jon Rowe, #2680)
41
+
42
+ ### 3.9.0 / 2019-10-07
43
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.8.2...v3.9.0)
44
+
45
+ Enhancements:
46
+
47
+ * Improve the handling of errors during loading support files, if a file
48
+ errors before loading specs, RSpec will now skip loading the specs.
49
+ (David Rodríguez, #2568)
50
+ * Add support for --example-matches to run examples by regular expression.
51
+ (Sam Joseph, Matt Rider, @okothkongo1, #2586)
52
+ * Add `did_you_mean` suggestions for file names encountering a `LoadError`
53
+ outside of examples. (@obromios, #2601)
54
+ * Add a minimalist quick fix style formatter, only outputs failures as
55
+ `file:line:message`. (Romain Tartière, #2614)
56
+ * Convert string number values to integer when used for `RSpec::Configuration#fail_fast`
57
+ (Viktor Fonic, #2634)
58
+ * Issue warning when invalid values are used for `RSpec::Configuration#fail_fast`
59
+ (Viktor Fonic, #2634)
60
+ * Add support for running the Rake task in a clean environment.
61
+ (Jon Rowe, #2632)
62
+ * Indent messages by there example group / example in the documentation formatter.
63
+ (Samuel Williams, #2649)
64
+
65
+ ### 3.8.2 / 2019-06-29
66
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.8.1...v3.8.2)
67
+
68
+ Bug Fixes:
69
+
70
+ * Fix `config.define_derived_metadata` so that cascades are not triggered
71
+ until metadata has been assigned to the example or example group
72
+ (Myron Marston, #2635).
73
+
1
74
  ### 3.8.1 / 2019-06-13
2
- [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.8.0...3-8-maintenance)
75
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.8.0...v3.8.1)
3
76
 
4
77
  Bug Fixes:
5
78
 
@@ -2088,6 +2161,7 @@ Bug fixes
2088
2161
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v2.2.0...v2.2.1)
2089
2162
 
2090
2163
  Bug fixes
2164
+
2091
2165
  * alias_method instead of override Kernel#method_missing (John Wilger)
2092
2166
  * changed --autotest to --tty in generated command (MIKAMI Yoshiyuki)
2093
2167
  * 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
@@ -289,7 +314,8 @@ module RSpec
289
314
  # Report the times for the slowest examples (default: `false`).
290
315
  # Use this to specify the number of examples to include in the profile.
291
316
  # @return [Boolean]
292
- add_setting :profile_examples
317
+ attr_writer :profile_examples
318
+ define_predicate :profile_examples
293
319
 
294
320
  # @macro add_setting
295
321
  # Run all examples if none match the configured filters
@@ -1106,7 +1132,7 @@ module RSpec
1106
1132
  #
1107
1133
  # # This lets you do this:
1108
1134
  #
1109
- # describe Thing do
1135
+ # RSpec.describe Thing do
1110
1136
  # pending "does something" do
1111
1137
  # thing = Thing.new
1112
1138
  # end
@@ -1114,7 +1140,7 @@ module RSpec
1114
1140
  #
1115
1141
  # # ... which is the equivalent of
1116
1142
  #
1117
- # describe Thing do
1143
+ # RSpec.describe Thing do
1118
1144
  # it "does something", :pending => true do
1119
1145
  # thing = Thing.new
1120
1146
  # end
@@ -1167,7 +1193,7 @@ module RSpec
1167
1193
  #
1168
1194
  # # allows the user to include a shared example group like:
1169
1195
  #
1170
- # describe Entity do
1196
+ # RSpec.describe Entity do
1171
1197
  # it_has_behavior 'sortability' do
1172
1198
  # let(:sortable) { Entity.new }
1173
1199
  # end
@@ -1327,6 +1353,12 @@ module RSpec
1327
1353
  # end
1328
1354
  # end
1329
1355
  #
1356
+ # module PreferencesHelpers
1357
+ # def preferences(user, preferences = {})
1358
+ # # ...
1359
+ # end
1360
+ # end
1361
+ #
1330
1362
  # module UserHelpers
1331
1363
  # def users(username)
1332
1364
  # # ...
@@ -1335,12 +1367,17 @@ module RSpec
1335
1367
  #
1336
1368
  # RSpec.configure do |config|
1337
1369
  # config.include(UserHelpers) # included in all groups
1370
+ #
1371
+ # # included in examples with `:preferences` metadata
1372
+ # config.include(PreferenceHelpers, :preferences)
1373
+ #
1374
+ # # included in examples with `:type => :request` metadata
1338
1375
  # config.include(AuthenticationHelpers, :type => :request)
1339
1376
  # end
1340
1377
  #
1341
- # describe "edit profile", :type => :request do
1378
+ # describe "edit profile", :preferences, :type => :request do
1342
1379
  # it "can be viewed by owning user" do
1343
- # login_as users(:jdoe)
1380
+ # login_as preferences(users(:jdoe), :lang => 'es')
1344
1381
  # get "/profiles/jdoe"
1345
1382
  # assert_select ".username", :text => 'jdoe'
1346
1383
  # end
@@ -1368,17 +1405,21 @@ module RSpec
1368
1405
  #
1369
1406
  # @example
1370
1407
  #
1371
- # RSpec.shared_context "example users" do
1408
+ # RSpec.shared_context "example admin user" do
1372
1409
  # let(:admin_user) { create_user(:admin) }
1410
+ # end
1411
+ #
1412
+ # RSpec.shared_context "example guest user" do
1373
1413
  # let(:guest_user) { create_user(:guest) }
1374
1414
  # end
1375
1415
  #
1376
1416
  # RSpec.configure do |config|
1377
- # config.include_context "example users", :type => :request
1417
+ # config.include_context "example guest user", :type => :request
1418
+ # config.include_context "example admin user", :admin, :type => :request
1378
1419
  # end
1379
1420
  #
1380
1421
  # RSpec.describe "The admin page", :type => :request do
1381
- # it "can be viewed by admins" do
1422
+ # it "can be viewed by admins", :admin do
1382
1423
  # login_with admin_user
1383
1424
  # get "/admin"
1384
1425
  # expect(response).to be_ok
@@ -1420,12 +1461,20 @@ module RSpec
1420
1461
  # end
1421
1462
  # end
1422
1463
  #
1464
+ # module PermissionHelpers
1465
+ # def define_permissions
1466
+ # # ...
1467
+ # end
1468
+ # end
1469
+ #
1423
1470
  # RSpec.configure do |config|
1424
1471
  # config.extend(UiHelpers, :type => :request)
1472
+ # config.extend(PermissionHelpers, :with_permissions, :type => :request)
1425
1473
  # end
1426
1474
  #
1427
- # describe "edit profile", :type => :request do
1475
+ # describe "edit profile", :with_permissions, :type => :request do
1428
1476
  # run_in_browser
1477
+ # define_permissions
1429
1478
  #
1430
1479
  # it "does stuff in the client" do
1431
1480
  # # ...
@@ -1718,7 +1767,7 @@ module RSpec
1718
1767
  # rspec.expose_current_running_example_as :example
1719
1768
  # end
1720
1769
  #
1721
- # describe MyClass do
1770
+ # RSpec.describe MyClass do
1722
1771
  # before do
1723
1772
  # # `example` can be used here because of the above config.
1724
1773
  # do_something if example.metadata[:type] == "foo"
@@ -1883,7 +1932,8 @@ module RSpec
1883
1932
  #
1884
1933
  # This method differs from {Hooks#before} in only one way: it supports
1885
1934
  # the `:suite` scope. Hooks with the `:suite` scope will be run once before
1886
- # the first example of the entire suite is executed.
1935
+ # the first example of the entire suite is executed. Conditions passed along
1936
+ # with `:suite` are effectively ignored.
1887
1937
  #
1888
1938
  # @see #prepend_before
1889
1939
  # @see #after
@@ -1912,7 +1962,8 @@ module RSpec
1912
1962
  #
1913
1963
  # This method differs from {Hooks#prepend_before} in only one way: it supports
1914
1964
  # the `:suite` scope. Hooks with the `:suite` scope will be run once before
1915
- # the first example of the entire suite is executed.
1965
+ # the first example of the entire suite is executed. Conditions passed along
1966
+ # with `:suite` are effectively ignored.
1916
1967
  #
1917
1968
  # @see #before
1918
1969
  # @see #after
@@ -1936,7 +1987,8 @@ module RSpec
1936
1987
  #
1937
1988
  # This method differs from {Hooks#after} in only one way: it supports
1938
1989
  # the `:suite` scope. Hooks with the `:suite` scope will be run once after
1939
- # the last example of the entire suite is executed.
1990
+ # the last example of the entire suite is executed. Conditions passed along
1991
+ # with `:suite` are effectively ignored.
1940
1992
  #
1941
1993
  # @see #append_after
1942
1994
  # @see #before
@@ -1965,7 +2017,8 @@ module RSpec
1965
2017
  #
1966
2018
  # This method differs from {Hooks#append_after} in only one way: it supports
1967
2019
  # the `:suite` scope. Hooks with the `:suite` scope will be run once after
1968
- # the last example of the entire suite is executed.
2020
+ # the last example of the entire suite is executed. Conditions passed along
2021
+ # with `:suite` are effectively ignored.
1969
2022
  #
1970
2023
  # @see #append_after
1971
2024
  # @see #before
@@ -2051,6 +2104,11 @@ module RSpec
2051
2104
 
2052
2105
  def load_file_handling_errors(method, file)
2053
2106
  __send__(method, file)
2107
+ rescue LoadError => ex
2108
+ relative_file = Metadata.relative_path(file)
2109
+ suggestions = DidYouMean.new(relative_file).call
2110
+ reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.#{suggestions}")
2111
+ RSpec.world.wants_to_quit = true
2054
2112
  rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
2055
2113
  relative_file = Metadata.relative_path(file)
2056
2114
  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