rspec-core 2.99.2 → 3.0.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.
Files changed (165) hide show
  1. checksums.yaml +14 -6
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +103 -191
  5. data/License.txt +1 -0
  6. data/README.md +4 -25
  7. data/features/Upgrade.md +2 -14
  8. data/features/command_line/dry_run.feature +29 -0
  9. data/features/command_line/example_name_option.feature +1 -1
  10. data/features/command_line/fail_fast.feature +26 -0
  11. data/features/command_line/format_option.feature +3 -3
  12. data/features/command_line/line_number_option.feature +16 -11
  13. data/features/command_line/order.feature +2 -3
  14. data/features/command_line/pattern_option.feature +3 -3
  15. data/features/command_line/randomization.feature +63 -0
  16. data/features/command_line/require_option.feature +2 -2
  17. data/features/command_line/ruby.feature +1 -1
  18. data/features/configuration/alias_example_to.feature +13 -22
  19. data/features/configuration/{backtrace_clean_patterns.feature → backtrace_exclusion_patterns.feature} +17 -14
  20. data/features/configuration/custom_settings.feature +11 -11
  21. data/features/configuration/overriding_global_ordering.feature +93 -0
  22. data/features/configuration/profile.feature +13 -13
  23. data/features/configuration/read_options_from_file.feature +7 -7
  24. data/features/example_groups/basic_structure.feature +1 -1
  25. data/features/example_groups/shared_context.feature +8 -8
  26. data/features/example_groups/shared_examples.feature +6 -14
  27. data/features/expectation_framework_integration/configure_expectation_framework.feature +27 -122
  28. data/features/filtering/exclusion_filters.feature +2 -5
  29. data/features/filtering/inclusion_filters.feature +1 -5
  30. data/features/formatters/json_formatter.feature +2 -2
  31. data/features/formatters/text_formatter.feature +4 -4
  32. data/features/helper_methods/arbitrary_methods.feature +2 -2
  33. data/features/helper_methods/let.feature +5 -5
  34. data/features/helper_methods/modules.feature +5 -8
  35. data/features/hooks/around_hooks.feature +2 -2
  36. data/features/hooks/before_and_after_hooks.feature +14 -14
  37. data/features/hooks/filtering.feature +12 -14
  38. data/features/metadata/described_class.feature +1 -1
  39. data/features/metadata/user_defined.feature +16 -29
  40. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  41. data/features/mock_framework_integration/use_mocha.feature +1 -1
  42. data/features/mock_framework_integration/use_rr.feature +1 -1
  43. data/features/mock_framework_integration/use_rspec.feature +5 -5
  44. data/features/pending/pending_examples.feature +5 -5
  45. data/features/spec_files/arbitrary_file_suffix.feature +1 -1
  46. data/features/step_definitions/additional_cli_steps.rb +3 -3
  47. data/features/subject/explicit_subject.feature +8 -8
  48. data/features/subject/implicit_receiver.feature +29 -0
  49. data/features/subject/implicit_subject.feature +4 -4
  50. data/features/support/env.rb +10 -3
  51. data/features/support/require_expect_syntax_in_aruba_specs.rb +16 -0
  52. data/lib/rspec/core.rb +11 -48
  53. data/lib/rspec/core/backport_random.rb +302 -0
  54. data/lib/rspec/core/backtrace_formatter.rb +65 -0
  55. data/lib/rspec/core/command_line.rb +7 -18
  56. data/lib/rspec/core/configuration.rb +202 -507
  57. data/lib/rspec/core/configuration_options.rb +17 -30
  58. data/lib/rspec/core/example.rb +29 -39
  59. data/lib/rspec/core/example_group.rb +166 -259
  60. data/lib/rspec/core/filter_manager.rb +30 -47
  61. data/lib/rspec/core/flat_map.rb +17 -0
  62. data/lib/rspec/core/formatters.rb +0 -138
  63. data/lib/rspec/core/formatters/base_formatter.rb +46 -1
  64. data/lib/rspec/core/formatters/base_text_formatter.rb +38 -61
  65. data/lib/rspec/core/formatters/deprecation_formatter.rb +21 -52
  66. data/lib/rspec/core/formatters/helpers.rb +0 -28
  67. data/lib/rspec/core/formatters/html_formatter.rb +1 -1
  68. data/lib/rspec/core/formatters/json_formatter.rb +38 -9
  69. data/lib/rspec/core/formatters/snippet_extractor.rb +14 -5
  70. data/lib/rspec/core/hooks.rb +55 -39
  71. data/lib/rspec/core/memoized_helpers.rb +17 -167
  72. data/lib/rspec/core/metadata.rb +16 -64
  73. data/lib/rspec/core/option_parser.rb +30 -39
  74. data/lib/rspec/core/ordering.rb +154 -0
  75. data/lib/rspec/core/pending.rb +12 -69
  76. data/lib/rspec/core/project_initializer.rb +12 -10
  77. data/lib/rspec/core/rake_task.rb +5 -108
  78. data/lib/rspec/core/reporter.rb +15 -18
  79. data/lib/rspec/core/runner.rb +16 -30
  80. data/lib/rspec/core/shared_context.rb +3 -5
  81. data/lib/rspec/core/shared_example_group.rb +3 -51
  82. data/lib/rspec/core/shared_example_group/collection.rb +1 -19
  83. data/lib/rspec/core/version.rb +1 -1
  84. data/lib/rspec/core/warnings.rb +22 -0
  85. data/lib/rspec/core/world.rb +12 -8
  86. data/spec/command_line/order_spec.rb +20 -23
  87. data/spec/rspec/core/backtrace_formatter_spec.rb +216 -0
  88. data/spec/rspec/core/command_line_spec.rb +32 -48
  89. data/spec/rspec/core/configuration_options_spec.rb +19 -50
  90. data/spec/rspec/core/configuration_spec.rb +142 -713
  91. data/spec/rspec/core/drb_command_line_spec.rb +2 -0
  92. data/spec/rspec/core/dsl_spec.rb +0 -1
  93. data/spec/rspec/core/example_group_spec.rb +192 -223
  94. data/spec/rspec/core/example_spec.rb +40 -16
  95. data/spec/rspec/core/filter_manager_spec.rb +2 -2
  96. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -41
  97. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +5 -123
  98. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +2 -87
  99. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -3
  100. data/spec/rspec/core/formatters/{text_mate_formatted.html → html_formatted-1.8.7-jruby.html} +44 -25
  101. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +477 -0
  102. data/spec/rspec/core/formatters/{html_formatted.html → html_formatted-1.8.7.html} +42 -25
  103. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +425 -0
  104. data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +416 -0
  105. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +477 -0
  106. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +419 -0
  107. data/spec/rspec/core/formatters/html_formatted-2.0.0.html +425 -0
  108. data/spec/rspec/core/formatters/html_formatter_spec.rb +21 -46
  109. data/spec/rspec/core/formatters/json_formatter_spec.rb +97 -8
  110. data/spec/rspec/core/hooks_filtering_spec.rb +5 -5
  111. data/spec/rspec/core/hooks_spec.rb +61 -47
  112. data/spec/rspec/core/memoized_helpers_spec.rb +20 -322
  113. data/spec/rspec/core/metadata_spec.rb +1 -24
  114. data/spec/rspec/core/option_parser_spec.rb +20 -62
  115. data/spec/rspec/core/ordering_spec.rb +102 -0
  116. data/spec/rspec/core/pending_example_spec.rb +0 -40
  117. data/spec/rspec/core/project_initializer_spec.rb +1 -25
  118. data/spec/rspec/core/rake_task_spec.rb +5 -72
  119. data/spec/rspec/core/random_spec.rb +47 -0
  120. data/spec/rspec/core/reporter_spec.rb +23 -48
  121. data/spec/rspec/core/runner_spec.rb +31 -39
  122. data/spec/rspec/core/shared_context_spec.rb +3 -15
  123. data/spec/rspec/core/shared_example_group/collection_spec.rb +4 -17
  124. data/spec/rspec/core/shared_example_group_spec.rb +12 -45
  125. data/spec/rspec/core/{deprecation_spec.rb → warnings_spec.rb} +3 -1
  126. data/spec/rspec/core_spec.rb +4 -21
  127. data/spec/spec_helper.rb +41 -5
  128. data/spec/support/helper_methods.rb +0 -29
  129. data/spec/support/sandboxed_mock_space.rb +0 -16
  130. data/spec/support/shared_example_groups.rb +7 -36
  131. data/spec/support/stderr_splitter.rb +36 -0
  132. metadata +163 -157
  133. metadata.gz.sig +1 -0
  134. data/exe/autospec +0 -13
  135. data/features/Autotest.md +0 -38
  136. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
  137. data/features/subject/attribute_of_subject.feature +0 -124
  138. data/features/subject/one_liner_syntax.feature +0 -71
  139. data/lib/autotest/discover.rb +0 -10
  140. data/lib/autotest/rspec2.rb +0 -77
  141. data/lib/rspec/core/backtrace_cleaner.rb +0 -46
  142. data/lib/rspec/core/backward_compatibility.rb +0 -55
  143. data/lib/rspec/core/caller_filter.rb +0 -60
  144. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
  145. data/lib/rspec/core/deprecation.rb +0 -26
  146. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  147. data/lib/rspec/core/extensions/kernel.rb +0 -9
  148. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  149. data/lib/rspec/core/extensions/ordered.rb +0 -27
  150. data/lib/rspec/core/formatters/console_codes.rb +0 -42
  151. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  152. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  153. data/lib/rspec/core/minitest_assertions_adapter.rb +0 -28
  154. data/lib/rspec/core/test_unit_assertions_adapter.rb +0 -30
  155. data/spec/autotest/discover_spec.rb +0 -49
  156. data/spec/autotest/failed_results_re_spec.rb +0 -45
  157. data/spec/autotest/rspec_spec.rb +0 -133
  158. data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
  159. data/spec/rspec/core/caller_filter_spec.rb +0 -58
  160. data/spec/rspec/core/deprecations_spec.rb +0 -59
  161. data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
  162. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
  163. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  164. data/spec/rspec/core/pending_spec.rb +0 -27
  165. data/spec/support/silence_dsl_deprecations.rb +0 -32
@@ -1,6 +1,5 @@
1
1
  require 'spec_helper'
2
2
  require 'tmpdir'
3
- require 'pathname'
4
3
 
5
4
  module RSpec::Core
6
5
 
@@ -19,7 +18,7 @@ module RSpec::Core
19
18
 
20
19
  describe '#deprecation_stream' do
21
20
  it 'defaults to standard error' do
22
- expect(config.deprecation_stream).to eq $stderr
21
+ expect($rspec_core_without_stderr_monkey_patch.deprecation_stream).to eq STDERR
23
22
  end
24
23
 
25
24
  it 'is configurable' do
@@ -27,48 +26,17 @@ module RSpec::Core
27
26
  config.deprecation_stream = io
28
27
  expect(config.deprecation_stream).to eq io
29
28
  end
30
-
31
- context 'when the reporter has already been initialized' do
32
- before do
33
- config.reporter
34
- allow(config).to receive(:warn)
35
- end
36
-
37
- it 'prints a notice indicating the reconfigured output_stream will be ignored' do
38
- config.deprecation_stream = double("IO")
39
- expect(config).to have_received(:warn).with(/deprecation_stream.*#{__FILE__}:#{__LINE__ - 1}/)
40
- end
41
-
42
- it 'does not change the value of `output_stream`' do
43
- config.deprecation_stream = double("IO")
44
- expect(config.deprecation_stream).to eq($stderr)
45
- end
46
-
47
- it 'does not print a warning if set to the value it already has' do
48
- config.deprecation_stream = config.deprecation_stream
49
- expect(config).not_to have_received(:warn)
50
- end
51
- end
52
29
  end
53
30
 
54
- shared_examples_for "output_stream" do |attribute|
55
- define_method :attribute_value do
56
- config.__send__(attribute)
57
- end
58
-
59
- update_line = __LINE__ + 2
60
- define_method :update_attribute do |value|
61
- config.__send__(:"#{attribute}=", value)
62
- end
63
-
31
+ describe "#output_stream" do
64
32
  it 'defaults to standard output' do
65
- expect(attribute_value).to eq $stdout
33
+ expect(config.output_stream).to eq $stdout
66
34
  end
67
35
 
68
36
  it 'is configurable' do
69
37
  io = double 'output io'
70
- update_attribute(io)
71
- expect(attribute_value).to eq io
38
+ config.output_stream = io
39
+ expect(config.output_stream).to eq io
72
40
  end
73
41
 
74
42
  context 'when the reporter has already been initialized' do
@@ -78,54 +46,22 @@ module RSpec::Core
78
46
  end
79
47
 
80
48
  it 'prints a notice indicating the reconfigured output_stream will be ignored' do
81
- update_attribute(StringIO.new)
82
- expect(config).to have_received(:warn).with(/output_stream.*#{__FILE__}:#{update_line}/)
49
+ config.output_stream = StringIO.new
50
+ expect(config).to have_received(:warn).with(/output_stream.*#{__FILE__}:#{__LINE__ - 1}/)
83
51
  end
84
52
 
85
53
  it 'does not change the value of `output_stream`' do
86
- update_attribute(StringIO.new)
87
- expect(attribute_value).to eq($stdout)
54
+ config.output_stream = StringIO.new
55
+ expect(config.output_stream).to eq($stdout)
88
56
  end
89
57
 
90
58
  it 'does not print a warning if set to the value it already has' do
91
- update_attribute(attribute_value)
59
+ config.output_stream = config.output_stream
92
60
  expect(config).not_to have_received(:warn)
93
61
  end
94
62
  end
95
63
  end
96
64
 
97
- describe "#output_stream" do
98
- include_examples "output_stream", :output_stream
99
- end
100
-
101
- describe "#output" do
102
- include_examples "output_stream", :output
103
-
104
- specify 'the reader is deprecated' do
105
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /output/)
106
- config.output
107
- end
108
-
109
- specify 'the writer is deprecated' do
110
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /output=/)
111
- config.output = $stdout
112
- end
113
- end
114
-
115
- describe "#out" do
116
- include_examples "output_stream", :out
117
-
118
- specify 'the reader is deprecated' do
119
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /out/)
120
- config.out
121
- end
122
-
123
- specify 'the writer is deprecated' do
124
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /out=/)
125
- config.out = $stdout
126
- end
127
- end
128
-
129
65
  describe "#setup_load_path_and_require" do
130
66
  include_context "isolate load path mutation"
131
67
 
@@ -178,33 +114,6 @@ module RSpec::Core
178
114
  config.should_receive(:load).once
179
115
  config.load_spec_files
180
116
  end
181
-
182
- context "with rspec-1 loaded" do
183
- before { stub_const("Spec::VERSION::MAJOR", 1) }
184
-
185
- it "raises with a helpful message" do
186
- expect {
187
- config.load_spec_files
188
- }.to raise_error(/rspec-1 has been loaded/)
189
- end
190
- end
191
- end
192
-
193
- describe "#treat_symbols_as_metadata_keys_with_true_values?" do
194
- it 'defaults to false' do
195
- expect(config.treat_symbols_as_metadata_keys_with_true_values?).to be_falsey
196
- end
197
-
198
- it 'prints a deprecation warning when explicitly set to false since RSpec 3 will not support that' do
199
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
200
- config.treat_symbols_as_metadata_keys_with_true_values = false
201
- expect(config.treat_symbols_as_metadata_keys_with_true_values?).to be false
202
- end
203
-
204
- it 'can be set to true' do
205
- config.treat_symbols_as_metadata_keys_with_true_values = true
206
- expect(config.treat_symbols_as_metadata_keys_with_true_values?).to be_truthy
207
- end
208
117
  end
209
118
 
210
119
  describe "#mock_framework" do
@@ -250,40 +159,11 @@ module RSpec::Core
250
159
  it_behaves_like "a configurable framework adapter", :mock_with
251
160
 
252
161
  [:rspec, :mocha, :rr, :flexmock].each do |framework|
253
- context "with :#{framework}" do
162
+ context "with #{framework}" do
254
163
  it "requires the adapter for #{framework}" do
255
164
  config.should_receive(:require).with("rspec/core/mocking/with_#{framework}")
256
165
  config.mock_with framework
257
166
  end
258
-
259
- it "does not print a deprecation" do
260
- expect(RSpec).not_to receive(:deprecate)
261
- config.mock_with framework
262
- end
263
- end
264
-
265
- context "with #{framework.to_s.inspect}" do
266
- it "requires the adapter for #{framework}" do
267
- config.should_receive(:require).with("rspec/core/mocking/with_#{framework}")
268
- config.mock_with framework.to_s
269
- end
270
-
271
- it "prints a deprecation warning" do
272
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /mock_with/)
273
- config.mock_with framework.to_s
274
- end
275
- end
276
-
277
- context "with :the_#{framework}_adapter" do
278
- it "requires the adapter for #{framework}" do
279
- config.should_receive(:require).with("rspec/core/mocking/with_#{framework}")
280
- config.mock_with :"the_#{framework}_adapter"
281
- end
282
-
283
- it "prints a deprecation warning" do
284
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /mock_with/)
285
- config.mock_with :"the_#{framework}_adapter"
286
- end
287
167
  end
288
168
  end
289
169
 
@@ -305,28 +185,9 @@ module RSpec::Core
305
185
  end
306
186
  end
307
187
 
308
- context "with an unknown key" do
309
- it "uses the null adapter" do
310
- config.should_receive(:require).with('rspec/core/mocking/with_absolutely_nothing')
311
- config.mock_with :crazy_new_mocking_framework_ive_not_yet_heard_of
312
- end
313
-
314
- it "prints a deprecation warning" do
315
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /mock_with/)
316
- config.mock_with :crazy_new_mocking_framework_ive_not_yet_heard_of
317
- end
318
- end
319
-
320
- context "with :nothing" do
321
- it "uses the null adapter" do
322
- config.should_receive(:require).with('rspec/core/mocking/with_absolutely_nothing')
323
- config.mock_with :nothing
324
- end
325
-
326
- it "does not print a deprecation warning" do
327
- expect(RSpec).not_to receive(:deprecate)
328
- config.mock_with :nothing
329
- end
188
+ it "uses the null adapter when set to any unknown key" do
189
+ config.should_receive(:require).with('rspec/core/mocking/with_absolutely_nothing')
190
+ config.mock_with :crazy_new_mocking_framework_ive_not_yet_heard_of
330
191
  end
331
192
 
332
193
  context 'when there are already some example groups defined' do
@@ -367,92 +228,35 @@ module RSpec::Core
367
228
  end
368
229
  end
369
230
 
370
- def stub_expectation_adapters
371
- stub_const("Test::Unit::Assertions", Module.new)
372
- stub_const("Minitest::Assertions", Module.new)
373
- stub_const("RSpec::Core::TestUnitAssertionsAdapter", Module.new)
374
- stub_const("RSpec::Core::MinitestAssertionsAdapter", Module.new)
375
- allow(config).to receive(:require)
376
- end
377
-
378
231
  describe "#expect_with" do
379
232
  before do
380
- stub_expectation_adapters
233
+ stub_const("Test::Unit::Assertions", Module.new)
234
+ config.stub(:require)
381
235
  end
382
236
 
383
237
  it_behaves_like "a configurable framework adapter", :expect_with
384
238
 
385
- context "with :stdlib" do
386
- it "is deprecated" do
387
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1, /:stdlib/
388
- config.expect_with :stdlib
389
- end
390
-
391
- it "requires test/unit/assertions" do
392
- expect(config).to receive(:require).with('test/unit/assertions')
393
- config.expect_with :stdlib
394
- end
395
-
396
- it "sets the expectation framework to ::Test::Unit::Assertions" do
397
- config.expect_with :stdlib
398
- expect(config.expectation_frameworks).to eq [::Test::Unit::Assertions]
399
- end
400
- end
401
-
402
- context "with :rspec" do
403
- it "requires rspec/expectations" do
404
- expect(config).to receive(:require).with('rspec/expectations')
405
- config.expect_with :rspec
406
- end
407
-
408
- it "sets the expectation framework to ::RSpec::Matchers" do
409
- config.expect_with :rspec
410
- expect(config.expectation_frameworks).to eq [::RSpec::Matchers]
411
- end
412
- end
413
-
414
- context "with :test_unit" do
415
- it "requires rspec/core/test_unit_assertions_adapter" do
416
- expect(config).to receive(:require).
417
- with('rspec/core/test_unit_assertions_adapter')
418
- config.expect_with :test_unit
419
- end
420
-
421
- it "sets the expectation framework to ::Test::Unit::Assertions" do
422
- config.expect_with :test_unit
423
- expect(config.expectation_frameworks).to eq [
424
- ::RSpec::Core::TestUnitAssertionsAdapter
425
- ]
426
- end
427
- end
428
-
429
- context "with :minitest" do
430
- it "requires rspec/core/minitest_assertions_adapter" do
431
- expect(config).to receive(:require).
432
- with('rspec/core/minitest_assertions_adapter')
433
- config.expect_with :minitest
434
- end
435
-
436
- it "sets the expectation framework to ::Minitest::Assertions" do
437
- config.expect_with :minitest
438
- expect(config.expectation_frameworks).to eq [
439
- ::RSpec::Core::MinitestAssertionsAdapter
440
- ]
239
+ [
240
+ [:rspec, 'rspec/expectations'],
241
+ [:stdlib, 'test/unit/assertions']
242
+ ].each do |framework, required_file|
243
+ context "with #{framework}" do
244
+ it "requires #{required_file}" do
245
+ config.should_receive(:require).with(required_file)
246
+ config.expect_with framework
247
+ end
441
248
  end
442
249
  end
443
250
 
444
251
  it "supports multiple calls" do
445
252
  config.expect_with :rspec
446
- config.expect_with :minitest
447
- expect(config.expectation_frameworks).to eq [
448
- RSpec::Matchers,
449
- RSpec::Core::MinitestAssertionsAdapter
450
- ]
253
+ config.expect_with :stdlib
254
+ expect(config.expectation_frameworks).to eq [RSpec::Matchers, Test::Unit::Assertions]
451
255
  end
452
256
 
453
257
  it "raises if block given with multiple args" do
454
258
  expect {
455
- config.expect_with :rspec, :minitest do |mod_config|
259
+ config.expect_with :rspec, :stdlib do |mod_config|
456
260
  end
457
261
  }.to raise_error(/expect_with only accepts/)
458
262
  end
@@ -480,16 +284,17 @@ module RSpec::Core
480
284
  it 'does not raise an error if re-setting the same config' do
481
285
  groups = []
482
286
  RSpec.world.stub(:example_groups => groups)
483
- config.expect_with :minitest
287
+ config.expect_with :stdlib
484
288
  groups << double.as_null_object
485
- config.expect_with :minitest
289
+ config.expect_with :stdlib
486
290
  end
487
291
  end
488
292
  end
489
293
 
490
294
  describe "#expecting_with_rspec?" do
491
295
  before do
492
- stub_expectation_adapters
296
+ stub_const("Test::Unit::Assertions", Module.new)
297
+ config.stub(:require)
493
298
  end
494
299
 
495
300
  it "returns false by default" do
@@ -501,18 +306,18 @@ module RSpec::Core
501
306
  expect(config).to be_expecting_with_rspec
502
307
  end
503
308
 
504
- it "returns true when `expect_with :rspec, :minitest` has been configured" do
505
- config.expect_with :rspec, :minitest
309
+ it "returns true when `expect_with :rspec, :stdlib` has been configured" do
310
+ config.expect_with :rspec, :stdlib
506
311
  expect(config).to be_expecting_with_rspec
507
312
  end
508
313
 
509
- it "returns true when `expect_with :minitest, :rspec` has been configured" do
510
- config.expect_with :minitest, :rspec
314
+ it "returns true when `expect_with :stdlib, :rspec` has been configured" do
315
+ config.expect_with :stdlib, :rspec
511
316
  expect(config).to be_expecting_with_rspec
512
317
  end
513
318
 
514
- it "returns false when `expect_with :minitest` has been configured" do
515
- config.expect_with :minitest
319
+ it "returns false when `expect_with :stdlib` has been configured" do
320
+ config.expect_with :stdlib
516
321
  expect(config).not_to be_expecting_with_rspec
517
322
  end
518
323
  end
@@ -655,20 +460,8 @@ module RSpec::Core
655
460
  end
656
461
  end
657
462
 
658
- specify "#filename_pattern is deprecated" do
659
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1
660
- config.filename_pattern
661
- end
662
-
663
- specify "#filename_pattern= is deprecated" do
664
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1
665
- config.filename_pattern = "/whatever"
666
- end
667
-
668
463
  %w[pattern= filename_pattern=].each do |setter|
669
464
  describe "##{setter}" do
670
- before { allow_deprecation } if setter == "filename_pattern="
671
-
672
465
  context "with single pattern" do
673
466
  before { config.send(setter, "**/*_foo.rb") }
674
467
  it "loads files following pattern" do
@@ -718,16 +511,15 @@ module RSpec::Core
718
511
 
719
512
  context "after files have already been loaded" do
720
513
  it 'will warn that it will have no effect' do
721
- allow(Kernel).to receive(:warn)
514
+ expect_warning_with_call_site(__FILE__, __LINE__ + 2, /has no effect/)
722
515
  config.load_spec_files
723
- config.send(setter, "rspec/**/*.spec"); line = __LINE__
724
- expect(Kernel).to have_received(:warn).with(/has no effect.*#{__FILE__}:#{line}/)
516
+ config.send(setter, "rspec/**/*.spec")
725
517
  end
726
518
 
727
519
  it 'will not warn if reset is called after load_spec_files' do
728
520
  config.load_spec_files
729
521
  config.reset
730
- expect(Kernel).to_not receive(:warn)
522
+ expect(RSpec).to_not receive(:warning)
731
523
  config.send(setter, "rspec/**/*.spec")
732
524
  end
733
525
  end
@@ -884,53 +676,8 @@ module RSpec::Core
884
676
  end
885
677
  end
886
678
 
887
- specify '#color? is deprecated' do
888
- expect_deprecation_with_call_site __FILE__, __LINE__+1
889
- config.color?
890
- end
891
-
892
- specify "#color_enabled? is not deprecated" do
893
- expect_no_deprecation
894
- config.color_enabled?
895
- config.color_enabled? double("output")
896
- end
897
-
898
- specify '#color with no argument is not deprecated' do
899
- expect_no_deprecation
900
- config.color
901
- end
902
-
903
- specify '#color with a non tty output and color = true is deprecated' do
904
- allow(config.output_stream).to receive(:tty?).and_return(false)
905
- config.color = true
906
- expect_warn_deprecation_with_call_site __FILE__, __LINE__+1
907
- expect(config.color).to be_falsey
908
- end
909
-
910
- specify '#color with an argument is deprecated' do
911
- expect_deprecation_with_call_site __FILE__, __LINE__+1
912
- config.color config.output_stream
913
- end
914
-
915
- specify '#color_enabled with no argument is deprecated' do
916
- expect_deprecation_with_call_site __FILE__, __LINE__+1
917
- config.color_enabled
918
- end
919
-
920
- specify '#color_enabled with an argument is deprecated in favour of #color_enabled?' do
921
- expect_deprecation_with_call_site __FILE__, __LINE__+1
922
- config.color_enabled config.output_stream
923
- end
924
-
925
679
  %w[color color_enabled].each do |color_option|
926
680
  describe "##{color_option}=" do
927
- before { allow_deprecation } if color_option == 'color_enabled'
928
-
929
- specify "color_enabled is deprecated" do
930
- expect_deprecation_with_call_site __FILE__, __LINE__+1
931
- config.color_enabled = true
932
- end
933
-
934
681
  context "given true" do
935
682
  before { config.send "#{color_option}=", true }
936
683
 
@@ -991,7 +738,6 @@ module RSpec::Core
991
738
  @original_host = RbConfig::CONFIG['host_os']
992
739
  RbConfig::CONFIG['host_os'] = 'mingw'
993
740
  config.stub(:require)
994
- config.stub(:warn)
995
741
  end
996
742
 
997
743
  after do
@@ -1019,10 +765,13 @@ module RSpec::Core
1019
765
  end
1020
766
 
1021
767
  context "with ANSICON NOT available" do
768
+ before do
769
+ allow_warning
770
+ end
771
+
1022
772
  it "warns to install ANSICON" do
1023
773
  config.stub(:require) { raise LoadError }
1024
- config.should_receive(:warn).
1025
- with(/You must use ANSICON/)
774
+ expect_warning_with_call_site(__FILE__, __LINE__ + 1, /You must use ANSICON/)
1026
775
  config.send "#{color_option}=", true
1027
776
  end
1028
777
 
@@ -1089,7 +838,7 @@ module RSpec::Core
1089
838
  end
1090
839
 
1091
840
  it "requires a formatter file based on its fully qualified name" do
1092
- config.formatter_loader.should_receive(:require).with('rspec/custom_formatter') do
841
+ config.should_receive(:require).with('rspec/custom_formatter') do
1093
842
  stub_const("RSpec::CustomFormatter", Class.new(Formatters::BaseFormatter))
1094
843
  end
1095
844
  config.add_formatter "RSpec::CustomFormatter"
@@ -1097,7 +846,7 @@ module RSpec::Core
1097
846
  end
1098
847
 
1099
848
  it "raises NameError if class is unresolvable" do
1100
- config.formatter_loader.should_receive(:require).with('rspec/custom_formatter3')
849
+ config.should_receive(:require).with('rspec/custom_formatter3')
1101
850
  expect(lambda { config.add_formatter "RSpec::CustomFormatter3" }).to raise_error(NameError)
1102
851
  end
1103
852
 
@@ -1105,45 +854,13 @@ module RSpec::Core
1105
854
  expect(lambda { config.add_formatter :progresss }).to raise_error(ArgumentError)
1106
855
  end
1107
856
 
1108
- it 'warns of deprecation for old document aliases' do
1109
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1, 's'
1110
- config.add_formatter 's'
1111
- expect(config.formatters.first).to be_an_instance_of Formatters::DocumentationFormatter
1112
- end
1113
-
1114
- it 'warns of deprecation of the text mate formatter' do
1115
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1, /rspec-core/
1116
- config.add_formatter 't'
1117
- end
1118
-
1119
- it 'warns of deprecation of the shortcut for the text mate formatter' do
1120
- stub_const("::RSpec::Mate::Formatters::TextMateFormatter", double)
1121
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1, /shortcut/
1122
- config.add_formatter 't'
1123
- end
1124
-
1125
857
  context "with a 2nd arg defining the output" do
1126
- let(:path) { File.join(Dir.tmpdir, 'output.txt') }
1127
-
1128
858
  it "creates a file at that path and sets it as the output" do
859
+ path = File.join(Dir.tmpdir, 'output.txt')
1129
860
  config.add_formatter('doc', path)
1130
861
  expect(config.formatters.first.output).to be_a(File)
1131
862
  expect(config.formatters.first.output.path).to eq(path)
1132
863
  end
1133
-
1134
- it "accepts Pathname objects for file paths" do
1135
- pathname = Pathname.new(path)
1136
- config.add_formatter('doc', pathname)
1137
- expect(config.formatters.first.output).to be_a(File)
1138
- expect(config.formatters.first.output.path).to eq(path)
1139
- end
1140
- end
1141
- end
1142
-
1143
- describe "#formatters" do
1144
- it "is deprecated to mutate the array" do
1145
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1
1146
- config.formatters.clear
1147
864
  end
1148
865
  end
1149
866
 
@@ -1161,7 +878,6 @@ module RSpec::Core
1161
878
  end
1162
879
 
1163
880
  it "sets the filter with a symbol" do
1164
- RSpec.configuration.stub(:treat_symbols_as_metadata_keys_with_true_values? => true)
1165
881
  config.filter_run_including :foo
1166
882
  expect(config.inclusion_filter[:foo]).to be(true)
1167
883
  end
@@ -1173,18 +889,6 @@ module RSpec::Core
1173
889
  expect(config.inclusion_filter[:foo]).to be(true)
1174
890
  expect(config.inclusion_filter[:bar]).to be(false)
1175
891
  end
1176
-
1177
- context "given `:focused => true`" do
1178
- it "issues a deprecation warning" do
1179
- expect_warn_deprecation_with_call_site(__FILE__, __LINE__ + 1, /filter_run_including :focused/)
1180
- config.filter_run_including :focused => true
1181
- end
1182
-
1183
- it "issues a deprecation warning when using `filter_run`" do
1184
- expect_warn_deprecation_with_call_site(__FILE__, __LINE__ + 1, /filter_run :focused/)
1185
- config.filter_run :focused => true
1186
- end
1187
- end
1188
892
  end
1189
893
 
1190
894
  describe "#filter_run_excluding" do
@@ -1201,7 +905,6 @@ module RSpec::Core
1201
905
  end
1202
906
 
1203
907
  it "sets the filter using a symbol" do
1204
- RSpec.configuration.stub(:treat_symbols_as_metadata_keys_with_true_values? => true)
1205
908
  config.filter_run_excluding :foo
1206
909
  expect(config.exclusion_filter[:foo]).to be(true)
1207
910
  end
@@ -1224,7 +927,6 @@ module RSpec::Core
1224
927
 
1225
928
  describe "#inclusion_filter=" do
1226
929
  it "treats symbols as hash keys with true values when told to" do
1227
- RSpec.configuration.stub(:treat_symbols_as_metadata_keys_with_true_values? => true)
1228
930
  config.inclusion_filter = :foo
1229
931
  expect(config.inclusion_filter).to eq({:foo => true})
1230
932
  end
@@ -1271,9 +973,15 @@ module RSpec::Core
1271
973
  end
1272
974
  end
1273
975
 
976
+ describe "#treat_symbols_as_metadata_keys_with_true_values=" do
977
+ it 'is deprecated' do
978
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
979
+ config.treat_symbols_as_metadata_keys_with_true_values = true
980
+ end
981
+ end
982
+
1274
983
  describe "#exclusion_filter=" do
1275
984
  it "treats symbols as hash keys with true values when told to" do
1276
- RSpec.configuration.stub(:treat_symbols_as_metadata_keys_with_true_values? => true)
1277
985
  config.exclusion_filter = :foo
1278
986
  expect(config.exclusion_filter).to eq({:foo => true})
1279
987
  end
@@ -1286,8 +994,6 @@ module RSpec::Core
1286
994
  end
1287
995
 
1288
996
  describe "line_numbers=" do
1289
- before { config.filter_manager.stub(:warn) }
1290
-
1291
997
  it "sets the line numbers" do
1292
998
  config.line_numbers = ['37']
1293
999
  expect(config.filter).to eq({:line_numbers => [37]})
@@ -1318,34 +1024,19 @@ module RSpec::Core
1318
1024
  end
1319
1025
 
1320
1026
  describe "#full_backtrace=" do
1321
- context "given true" do
1322
- it "clears the backtrace exclusion patterns" do
1323
- config.full_backtrace = true
1324
- expect(config.backtrace_exclusion_patterns).to eq([])
1325
- end
1326
- end
1327
-
1328
- context "given false" do
1329
- it "restores backtrace clean patterns" do
1330
- config.full_backtrace = false
1331
- expect(config.backtrace_exclusion_patterns).to eq(RSpec::Core::BacktraceCleaner::DEFAULT_EXCLUSION_PATTERNS)
1332
- end
1333
- end
1334
-
1335
1027
  it "doesn't impact other instances of config" do
1336
1028
  config_1 = Configuration.new
1337
1029
  config_2 = Configuration.new
1338
1030
 
1339
1031
  config_1.full_backtrace = true
1340
- expect(config_2.backtrace_exclusion_patterns).not_to be_empty
1032
+ expect(config_2.full_backtrace?).to be_falsey
1341
1033
  end
1342
1034
  end
1343
1035
 
1344
- describe "#backtrace_clean_patterns=" do
1036
+ describe "#backtrace_exclusion_patterns=" do
1345
1037
  it "actually receives the new filter values" do
1346
- RSpec.stub(:deprecate)
1347
1038
  config = Configuration.new
1348
- config.backtrace_clean_patterns = [/.*/]
1039
+ config.backtrace_exclusion_patterns = [/.*/]
1349
1040
  expect(config.backtrace_formatter.exclude? "this").to be_truthy
1350
1041
  end
1351
1042
  end
@@ -1362,124 +1053,14 @@ module RSpec::Core
1362
1053
  end
1363
1054
  end
1364
1055
 
1365
- describe "#backtrace_clean_patterns" do
1366
- before { allow(RSpec).to receive(:deprecate) }
1367
- it "is deprecated" do
1368
- RSpec.should_receive(:deprecate)
1369
- config = Configuration.new
1370
- config.backtrace_clean_patterns
1371
- end
1372
-
1056
+ describe "#backtrace_exclusion_patterns" do
1373
1057
  it "can be appended to" do
1374
1058
  config = Configuration.new
1375
- config.backtrace_clean_patterns << /.*/
1059
+ config.backtrace_exclusion_patterns << /.*/
1376
1060
  expect(config.backtrace_formatter.exclude? "this").to be_truthy
1377
1061
  end
1378
1062
  end
1379
1063
 
1380
- specify "#backtrace_cleaner is deprecated" do
1381
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1
1382
- config.backtrace_cleaner
1383
- end
1384
-
1385
- describe ".backtrace_formatter#exclude? defaults" do
1386
- before { allow_deprecation }
1387
-
1388
- it "returns true for rspec files" do
1389
- expect(config.backtrace_formatter.exclude?("lib/rspec/core.rb")).to be_truthy
1390
- end
1391
-
1392
- it "returns true for spec_helper" do
1393
- expect(config.backtrace_formatter.exclude?("spec/spec_helper.rb")).to be_truthy
1394
- end
1395
-
1396
- it "returns true for java files (for JRuby)" do
1397
- expect(config.backtrace_formatter.exclude?("org/jruby/RubyArray.java:2336")).to be_truthy
1398
- end
1399
-
1400
- it "returns true for files within installed gems" do
1401
- expect(config.backtrace_formatter.exclude?('ruby-1.8.7-p334/gems/mygem-2.3.0/lib/mygem.rb')).to be_truthy
1402
- end
1403
-
1404
- it "returns false for files in projects containing 'gems' in the name" do
1405
- expect(config.backtrace_formatter.exclude?('code/my-gems-plugin/lib/plugin.rb')).to be_falsey
1406
- end
1407
-
1408
- it "returns false for something in the current working directory" do
1409
- expect(config.backtrace_formatter.exclude?("#{Dir.getwd}/arbitrary")).to be_falsey
1410
- end
1411
- end
1412
-
1413
- describe "#debug=true" do
1414
- before do
1415
- if defined?(Debugger)
1416
- @orig_debugger = Debugger
1417
- Object.send(:remove_const, :Debugger)
1418
- else
1419
- @orig_debugger = nil
1420
- end
1421
- config.stub(:require)
1422
- Object.const_set("Debugger", debugger)
1423
-
1424
- allow_deprecation
1425
- end
1426
-
1427
- after do
1428
- Object.send(:remove_const, :Debugger)
1429
- Object.const_set("Debugger", @orig_debugger) if @orig_debugger
1430
- end
1431
-
1432
- let(:debugger) { double('Debugger').as_null_object }
1433
-
1434
- it "requires 'ruby-debug'" do
1435
- config.should_receive(:require).with('ruby-debug')
1436
- config.debug = true
1437
- end
1438
-
1439
- it "starts the debugger" do
1440
- debugger.should_receive(:start)
1441
- config.debug = true
1442
- end
1443
-
1444
- it "warns that this feature is deprecated" do
1445
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
1446
- config.debug = true
1447
- end
1448
- end
1449
-
1450
- describe "#debug=false" do
1451
- before { allow_deprecation }
1452
-
1453
- it "does not require 'ruby-debug'" do
1454
- config.should_not_receive(:require).with('ruby-debug')
1455
- config.debug = false
1456
- end
1457
-
1458
- it "warns that this feature is deprecated" do
1459
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
1460
- config.debug = false
1461
- end
1462
- end
1463
-
1464
- describe "#debug?" do
1465
- before { allow_deprecation }
1466
-
1467
- it 'returns true if the debugger has been loaded' do
1468
- stub_const("Debugger", Object.new)
1469
- expect(config.debug?).to be_truthy
1470
- end
1471
-
1472
- it 'returns false if the debugger has not been loaded' do
1473
- hide_const("Debugger")
1474
- expect(config.debug?).to be_falsey
1475
- end
1476
-
1477
- it "warns that this feature is deprecated" do
1478
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
1479
- config.debug?
1480
- end
1481
- end
1482
-
1483
1064
  describe "#libs=" do
1484
1065
  include_context "isolate load path mutation"
1485
1066
 
@@ -1706,53 +1287,40 @@ module RSpec::Core
1706
1287
  end
1707
1288
 
1708
1289
  describe "#force" do
1709
- let(:collection) { [1, 2, 3, 4] }
1710
- let(:ordered) { config.group_ordering_block.call(collection) }
1290
+ context "for ordering options" do
1291
+ let(:list) { [1, 2, 3, 4] }
1292
+ let(:ordering_strategy) { config.ordering_registry.fetch(:global) }
1293
+ let(:rng) { RSpec::Core::RandomNumberGenerator.new config.seed }
1294
+ let(:shuffled) { Ordering::Random.new(config).shuffle list, rng }
1711
1295
 
1712
- it "forces order (when given default)" do
1713
- config.force :order => "default"
1714
- config.order = "rand"
1715
-
1716
- expect(config.order).to eq("default")
1717
- expect(ordered).to eq([1, 2, 3, 4])
1718
- end
1296
+ specify "CLI `--order defined` takes precedence over `config.order = rand`" do
1297
+ config.force :order => "defined"
1298
+ config.order = "rand"
1719
1299
 
1720
- it "forces order (when given defined)" do
1721
- config.force :order => "defined"
1722
- config.order = "rand"
1723
-
1724
- expect(config.order).to eq("defined")
1725
- expect(ordered).to eq([1, 2, 3, 4])
1726
- end
1727
-
1728
- it "forces order and seed with :order => 'rand:37'" do
1729
- config.force :order => "rand:37"
1730
- config.order = "default"
1731
-
1732
- expect(config.order).to eq("rand")
1733
- expect(config.seed).to eq(37)
1300
+ expect(ordering_strategy.order(list)).to eq([1, 2, 3, 4])
1301
+ end
1734
1302
 
1735
- allow(Kernel).to receive(:rand).and_return(3, 1, 4, 2)
1736
- expect(ordered).to_not eq([1, 2, 3, 4])
1737
- end
1303
+ specify "CLI `--order rand:37` takes precedence over `config.order = defined`" do
1304
+ config.force :order => "rand:37"
1305
+ config.order = "defined"
1738
1306
 
1739
- it "forces order and seed with :seed => '37'" do
1740
- config.force :seed => "37"
1741
- config.order = "defined"
1307
+ expect(ordering_strategy.order(list)).to eq(shuffled)
1308
+ end
1742
1309
 
1743
- expect(config.seed).to eq(37)
1744
- expect(config.order).to eq("rand")
1310
+ specify "CLI `--seed 37` forces order and seed" do
1311
+ config.force :seed => 37
1312
+ config.order = "defined"
1313
+ config.seed = 145
1745
1314
 
1746
- allow(Kernel).to receive(:rand).and_return(3, 1, 4, 2)
1747
- expect(ordered).to eq([2, 4, 1, 3])
1748
- end
1315
+ expect(ordering_strategy.order(list)).to eq(shuffled)
1316
+ expect(config.seed).to eq(37)
1317
+ end
1749
1318
 
1750
- it 'can set random ordering' do
1751
- config.force :seed => "rand:37"
1752
- RSpec.stub(:configuration => config)
1753
- list = [1, 2, 3, 4].extend(Extensions::Ordered::Examples)
1754
- Kernel.should_receive(:rand).and_return(3, 1, 4, 2)
1755
- expect(list.ordered).to eq([2, 4, 1, 3])
1319
+ specify "CLI `--order defined` takes precedence over `config.register_ordering(:global)`" do
1320
+ config.force :order => "defined"
1321
+ config.register_ordering(:global, &:reverse)
1322
+ expect(ordering_strategy.order(list)).to eq([1, 2, 3, 4])
1323
+ end
1756
1324
  end
1757
1325
 
1758
1326
  it "forces 'false' value" do
@@ -1773,195 +1341,97 @@ module RSpec::Core
1773
1341
  end
1774
1342
  end
1775
1343
 
1776
- describe '#randomize?' do
1777
- context 'with order set to :random' do
1778
- before { config.order = :random }
1779
-
1780
- it 'returns true' do
1781
- expect(config.randomize?).to be_truthy
1782
- end
1344
+ describe "#seed_used?" do
1345
+ def use_seed_on(registry)
1346
+ registry.fetch(:random).order([1, 2])
1783
1347
  end
1784
1348
 
1785
- context 'with order set to nil' do
1786
- before { config.order = nil }
1787
-
1788
- it 'returns false' do
1789
- expect(config.randomize?).to be_falsey
1790
- end
1349
+ it 'returns false if neither ordering registry used the seed' do
1350
+ expect(config.seed_used?).to be false
1791
1351
  end
1792
1352
 
1793
- it 'is deprecated' do
1794
- expect_warn_deprecation_with_call_site(__FILE__, __LINE__ + 1, /randomize\?/)
1795
- config.randomize?
1353
+ it 'returns true if the ordering registry used the seed' do
1354
+ use_seed_on(config.ordering_registry)
1355
+ expect(config.seed_used?).to be true
1796
1356
  end
1797
1357
  end
1798
1358
 
1799
1359
  describe '#order=' do
1800
- context 'given "random:123"' do
1801
- before { config.order = 'random:123' }
1360
+ context 'given "random"' do
1361
+ before do
1362
+ config.seed = 7654
1363
+ config.order = 'random'
1364
+ end
1802
1365
 
1803
- it 'sets order to "random"' do
1804
- expect(config.order).to eq('random')
1366
+ it 'does not change the seed' do
1367
+ expect(config.seed).to eq(7654)
1805
1368
  end
1806
1369
 
1370
+ it 'sets up random ordering' do
1371
+ RSpec.stub(:configuration => config)
1372
+ global_ordering = config.ordering_registry.fetch(:global)
1373
+ expect(global_ordering).to be_an_instance_of(Ordering::Random)
1374
+ end
1375
+ end
1376
+
1377
+ context 'given "random:123"' do
1378
+ before { config.order = 'random:123' }
1379
+
1807
1380
  it 'sets seed to 123' do
1808
1381
  expect(config.seed).to eq(123)
1809
1382
  end
1810
1383
 
1811
1384
  it 'sets up random ordering' do
1812
1385
  RSpec.stub(:configuration => config)
1813
- list = [1, 2, 3, 4].extend(Extensions::Ordered::Examples)
1814
- Kernel.should_receive(:rand).and_return(3, 1, 4, 2)
1815
- expect(list.ordered).to eq([2, 4, 1, 3])
1386
+ global_ordering = config.ordering_registry.fetch(:global)
1387
+ expect(global_ordering).to be_an_instance_of(Ordering::Random)
1816
1388
  end
1817
1389
  end
1818
1390
 
1819
- shared_examples_for "defined order" do |order|
1391
+ context 'given "defined"' do
1820
1392
  before do
1821
1393
  config.order = 'rand:123'
1822
- config.order = order
1823
- end
1824
-
1825
- it "sets the order to nil" do
1826
- expect(config.order).to be_nil
1394
+ config.order = 'defined'
1827
1395
  end
1828
1396
 
1829
- it "sets the seed to nil" do
1830
- expect(config.seed).to be_nil
1397
+ it "does not change the seed" do
1398
+ expect(config.seed).to eq(123)
1831
1399
  end
1832
1400
 
1833
1401
  it 'clears the random ordering' do
1834
1402
  RSpec.stub(:configuration => config)
1835
- list = [1, 2, 3, 4].extend(Extensions::Ordered::Examples)
1836
- Kernel.should_not_receive(:rand)
1837
- expect(list.ordered).to eq([1, 2, 3, 4])
1838
- end
1839
- end
1840
-
1841
- context "given 'default'" do
1842
- include_examples "defined order", 'default'
1843
-
1844
- it 'prints a deprecation notice' do
1845
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /default/)
1846
- config.order = 'default'
1403
+ list = [1, 2, 3, 4]
1404
+ ordering_strategy = config.ordering_registry.fetch(:global)
1405
+ expect(ordering_strategy.order(list)).to eq([1, 2, 3, 4])
1847
1406
  end
1848
1407
  end
1849
-
1850
- context "given 'defined'" do
1851
- include_examples "defined order", 'defined'
1852
- end
1853
- end
1854
-
1855
- describe "#order_examples" do
1856
- before do
1857
- allow_deprecation
1858
- RSpec.stub(:configuration => config)
1859
- end
1860
-
1861
- it 'sets a block that determines the ordering of a collection extended with Extensions::Ordered::Examples' do
1862
- examples = [1, 2, 3, 4]
1863
- examples.extend Extensions::Ordered::Examples
1864
- config.order_examples { |examples_to_order| examples_to_order.reverse }
1865
- expect(examples.ordered).to eq([4, 3, 2, 1])
1866
- end
1867
-
1868
- it 'sets #order to "custom"' do
1869
- config.order_examples { |examples| examples.reverse }
1870
- expect(config.order).to eq("custom")
1871
- end
1872
-
1873
- it 'prints a deprecation warning' do
1874
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /RSpec::Configuration#order_examples/)
1875
- config.order_examples { }
1876
- end
1877
- end
1878
-
1879
- describe "#example_ordering_block" do
1880
- it 'defaults to a block that returns the passed argument' do
1881
- expect(config.example_ordering_block.call([1, 2, 3])).to eq([1, 2, 3])
1882
- end
1883
1408
  end
1884
1409
 
1885
- describe "#order_groups" do
1886
- before do
1887
- allow_deprecation
1888
- RSpec.stub(:configuration => config)
1889
- end
1890
-
1891
- it 'sets a block that determines the ordering of a collection extended with Extensions::Ordered::ExampleGroups' do
1892
- groups = [1, 2, 3, 4]
1893
- groups.extend Extensions::Ordered::ExampleGroups
1894
- config.order_groups { |groups_to_order| groups_to_order.reverse }
1895
- expect(groups.ordered).to eq([4, 3, 2, 1])
1896
- end
1897
-
1898
- it 'sets #order to "custom"' do
1899
- config.order_groups { |groups| groups.reverse }
1900
- expect(config.order).to eq("custom")
1410
+ describe "#register_ordering" do
1411
+ def register_reverse_ordering
1412
+ config.register_ordering(:reverse, &:reverse)
1901
1413
  end
1902
1414
 
1903
- it 'prints a deprecation warning' do
1904
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /RSpec::Configuration#order_groups/)
1905
- config.order_groups { }
1906
- end
1907
- end
1415
+ it 'stores the ordering for later use' do
1416
+ register_reverse_ordering
1908
1417
 
1909
- describe "#group_ordering_block" do
1910
- it 'defaults to a block that returns the passed argument' do
1911
- expect(config.group_ordering_block.call([1, 2, 3])).to eq([1, 2, 3])
1418
+ list = [1, 2, 3]
1419
+ strategy = config.ordering_registry.fetch(:reverse)
1420
+ expect(strategy).to be_a(Ordering::Custom)
1421
+ expect(strategy.order(list)).to eq([3, 2, 1])
1912
1422
  end
1913
- end
1914
1423
 
1915
- describe "#order_groups_and_examples" do
1916
- let(:examples) { [1, 2, 3, 4].extend Extensions::Ordered::Examples }
1917
- let(:groups) { [1, 2, 3, 4].extend Extensions::Ordered::ExampleGroups }
1918
-
1919
- before do
1920
- RSpec.stub(:configuration => config)
1921
- config.order_groups_and_examples { |list| list.reverse }
1922
- end
1923
-
1924
- it 'sets a block that determines the ordering of a collection extended with Extensions::Ordered::Examples' do
1925
- expect(examples.ordered).to eq([4, 3, 2, 1])
1926
- end
1927
-
1928
- it 'sets a block that determines the ordering of a collection extended with Extensions::Ordered::ExampleGroups' do
1929
- expect(groups.ordered).to eq([4, 3, 2, 1])
1930
- end
1931
- end
1932
-
1933
- describe "#register_ordering(:global)" do
1934
- let(:examples) { [1, 2, 3, 4].extend Extensions::Ordered::Examples }
1935
- let(:groups) { [1, 2, 3, 4].extend Extensions::Ordered::ExampleGroups }
1936
-
1937
- before do
1938
- RSpec.stub(:configuration => config)
1939
- config.register_ordering(:global) { |list| list.reverse }
1940
- end
1941
-
1942
- it 'sets a block that determines the ordering of a collection extended with Extensions::Ordered::Examples' do
1943
- expect(examples.ordered).to eq([4, 3, 2, 1])
1944
- end
1945
-
1946
- it 'sets a block that determines the ordering of a collection extended with Extensions::Ordered::ExampleGroups' do
1947
- expect(groups.ordered).to eq([4, 3, 2, 1])
1948
- end
1949
-
1950
- it 'sets #order to "custom"' do
1951
- expect(config.order).to eq("custom")
1952
- end
1953
-
1954
- it 'raises an ArgumentError if given a symbol other than `:global`' do
1955
- expect {
1956
- config.register_ordering(:custom) { }
1957
- }.to raise_error(ArgumentError, /:global/)
1958
- end
1959
- end
1424
+ it 'can register an ordering object' do
1425
+ strategy = Object.new
1426
+ def strategy.order(list)
1427
+ list.reverse
1428
+ end
1960
1429
 
1961
- describe "#order" do
1962
- it 'is deprecated' do
1963
- expect_warn_deprecation_with_call_site(__FILE__, __LINE__ + 1, /order/)
1964
- config.order
1430
+ config.register_ordering(:reverse, strategy)
1431
+ list = [1, 2, 3]
1432
+ fetched = config.ordering_registry.fetch(:reverse)
1433
+ expect(fetched).to be(strategy)
1434
+ expect(fetched.order(list)).to eq([3, 2, 1])
1965
1435
  end
1966
1436
  end
1967
1437
 
@@ -1982,12 +1452,7 @@ module RSpec::Core
1982
1452
  expect($VERBOSE).to eq false
1983
1453
  end
1984
1454
 
1985
- it 'returns the verbosity setting as a predicate' do
1986
- expect(config.warnings?).to eq $VERBOSE
1987
- end
1988
-
1989
- it 'warns when using the deprecated `warnings` reader' do
1990
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /warnings/)
1455
+ it 'returns the verbosity setting' do
1991
1456
  expect(config.warnings).to eq $VERBOSE
1992
1457
  end
1993
1458
 
@@ -2030,42 +1495,6 @@ module RSpec::Core
2030
1495
  expect(value_1.description).to eq("works")
2031
1496
  expect(value_2).to be(value_1)
2032
1497
  end
2033
-
2034
- [:example, :running_example].each do |name|
2035
- it "silences the deprecation warning for ##{name} when configured to expose via that name" do
2036
- RSpec.configuration.expose_current_running_example_as name
2037
- allow(RSpec).to receive(:deprecate)
2038
-
2039
- ExampleGroup.describe "Group" do
2040
- specify { __send__(name) }
2041
- end.run
2042
-
2043
- expect(RSpec).to_not have_received(:deprecate)
2044
- end
2045
- end
2046
- end
2047
-
2048
- describe '#show_failures_in_pending_blocks' do
2049
- specify 'reader is deprecated' do
2050
- expect_warn_deprecation_with_call_site(__FILE__, __LINE__ + 3,
2051
- /show_failures_in_pending_blocks/)
2052
-
2053
- config.show_failures_in_pending_blocks
2054
- end
2055
-
2056
- specify 'predicate is deprecated' do
2057
- expect_warn_deprecation_with_call_site(__FILE__, __LINE__ + 3,
2058
- /show_failures_in_pending_blocks/)
2059
-
2060
- config.show_failures_in_pending_blocks?
2061
- end
2062
-
2063
- specify 'writer is deprecated' do
2064
- expect_warn_deprecation_with_call_site(__FILE__, __LINE__ + 3,
2065
- /show_failures_in_pending_blocks/)
2066
-
2067
- config.show_failures_in_pending_blocks = true
2068
- end
2069
1498
  end
2070
1499
 
2071
1500
  end