rspec-core 2.99.0.beta2 → 2.99.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/Changelog.md +122 -43
  3. data/features/command_line/line_number_option.feature +6 -11
  4. data/features/configuration/read_options_from_file.feature +2 -2
  5. data/features/expectation_framework_integration/configure_expectation_framework.feature +120 -25
  6. data/lib/autotest/discover.rb +10 -1
  7. data/lib/autotest/rspec2.rb +1 -1
  8. data/lib/rspec/core/command_line.rb +16 -5
  9. data/lib/rspec/core/configuration.rb +151 -119
  10. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +32 -0
  11. data/lib/rspec/core/example.rb +3 -1
  12. data/lib/rspec/core/example_group.rb +174 -125
  13. data/lib/rspec/core/filter_manager.rb +48 -10
  14. data/lib/rspec/core/formatters.rb +137 -0
  15. data/lib/rspec/core/formatters/base_text_formatter.rb +25 -29
  16. data/lib/rspec/core/formatters/console_codes.rb +42 -0
  17. data/lib/rspec/core/formatters/deprecation_formatter.rb +14 -5
  18. data/lib/rspec/core/formatters/helpers.rb +1 -1
  19. data/lib/rspec/core/memoized_helpers.rb +2 -1
  20. data/lib/rspec/core/metadata.rb +63 -1
  21. data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
  22. data/lib/rspec/core/option_parser.rb +20 -1
  23. data/lib/rspec/core/pending.rb +26 -4
  24. data/lib/rspec/core/reporter.rb +1 -1
  25. data/lib/rspec/core/runner.rb +2 -2
  26. data/lib/rspec/core/shared_example_group.rb +11 -4
  27. data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
  28. data/lib/rspec/core/version.rb +1 -1
  29. data/lib/rspec/core/world.rb +2 -2
  30. data/spec/autotest/discover_spec.rb +38 -8
  31. data/spec/rspec/core/command_line_spec.rb +47 -29
  32. data/spec/rspec/core/configuration_options_spec.rb +1 -1
  33. data/spec/rspec/core/configuration_spec.rb +223 -37
  34. data/spec/rspec/core/example_group_spec.rb +116 -6
  35. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +24 -4
  36. data/spec/rspec/core/formatters/console_codes_spec.rb +50 -0
  37. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +20 -3
  38. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +1 -0
  39. data/spec/rspec/core/formatters/html_formatted.html +3 -4
  40. data/spec/rspec/core/formatters/html_formatter_spec.rb +10 -4
  41. data/spec/rspec/core/formatters/text_mate_formatted.html +3 -4
  42. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +9 -3
  43. data/spec/rspec/core/hooks_filtering_spec.rb +5 -5
  44. data/spec/rspec/core/memoized_helpers_spec.rb +38 -0
  45. data/spec/rspec/core/metadata_spec.rb +24 -1
  46. data/spec/rspec/core/option_parser_spec.rb +39 -2
  47. data/spec/rspec/core/pending_example_spec.rb +14 -0
  48. data/spec/rspec/core/pending_spec.rb +27 -0
  49. data/spec/rspec/core/runner_spec.rb +3 -3
  50. data/spec/rspec/core/shared_context_spec.rb +1 -1
  51. data/spec/rspec/core/shared_example_group_spec.rb +18 -0
  52. data/spec/support/helper_methods.rb +4 -0
  53. metadata +105 -106
@@ -75,7 +75,7 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
75
75
  expect(config.exclusion_filter).to have_key(:slow)
76
76
  end
77
77
 
78
- it "forces color_enabled" do
78
+ it "forces color" do
79
79
  opts = config_options_object(*%w[--color])
80
80
  config = RSpec::Core::Configuration.new
81
81
  config.should_receive(:force).with(:color => true)
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'tmpdir'
3
+ require 'pathname'
3
4
 
4
5
  module RSpec::Core
5
6
 
@@ -26,6 +27,28 @@ module RSpec::Core
26
27
  config.deprecation_stream = io
27
28
  expect(config.deprecation_stream).to eq io
28
29
  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
29
52
  end
30
53
 
31
54
  shared_examples_for "output_stream" do |attribute|
@@ -344,35 +367,92 @@ module RSpec::Core
344
367
  end
345
368
  end
346
369
 
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
+
347
378
  describe "#expect_with" do
348
379
  before do
349
- stub_const("Test::Unit::Assertions", Module.new)
350
- config.stub(:require)
380
+ stub_expectation_adapters
351
381
  end
352
382
 
353
383
  it_behaves_like "a configurable framework adapter", :expect_with
354
384
 
355
- [
356
- [:rspec, 'rspec/expectations'],
357
- [:stdlib, 'test/unit/assertions']
358
- ].each do |framework, required_file|
359
- context "with #{framework}" do
360
- it "requires #{required_file}" do
361
- config.should_receive(:require).with(required_file)
362
- config.expect_with framework
363
- end
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
+ ]
364
441
  end
365
442
  end
366
443
 
367
444
  it "supports multiple calls" do
368
445
  config.expect_with :rspec
369
- config.expect_with :stdlib
370
- expect(config.expectation_frameworks).to eq [RSpec::Matchers, Test::Unit::Assertions]
446
+ config.expect_with :minitest
447
+ expect(config.expectation_frameworks).to eq [
448
+ RSpec::Matchers,
449
+ RSpec::Core::MinitestAssertionsAdapter
450
+ ]
371
451
  end
372
452
 
373
453
  it "raises if block given with multiple args" do
374
454
  expect {
375
- config.expect_with :rspec, :stdlib do |mod_config|
455
+ config.expect_with :rspec, :minitest do |mod_config|
376
456
  end
377
457
  }.to raise_error(/expect_with only accepts/)
378
458
  end
@@ -400,17 +480,16 @@ module RSpec::Core
400
480
  it 'does not raise an error if re-setting the same config' do
401
481
  groups = []
402
482
  RSpec.world.stub(:example_groups => groups)
403
- config.expect_with :stdlib
483
+ config.expect_with :minitest
404
484
  groups << double.as_null_object
405
- config.expect_with :stdlib
485
+ config.expect_with :minitest
406
486
  end
407
487
  end
408
488
  end
409
489
 
410
490
  describe "#expecting_with_rspec?" do
411
491
  before do
412
- stub_const("Test::Unit::Assertions", Module.new)
413
- config.stub(:require)
492
+ stub_expectation_adapters
414
493
  end
415
494
 
416
495
  it "returns false by default" do
@@ -422,18 +501,18 @@ module RSpec::Core
422
501
  expect(config).to be_expecting_with_rspec
423
502
  end
424
503
 
425
- it "returns true when `expect_with :rspec, :stdlib` has been configured" do
426
- config.expect_with :rspec, :stdlib
504
+ it "returns true when `expect_with :rspec, :minitest` has been configured" do
505
+ config.expect_with :rspec, :minitest
427
506
  expect(config).to be_expecting_with_rspec
428
507
  end
429
508
 
430
- it "returns true when `expect_with :stdlib, :rspec` has been configured" do
431
- config.expect_with :stdlib, :rspec
509
+ it "returns true when `expect_with :minitest, :rspec` has been configured" do
510
+ config.expect_with :minitest, :rspec
432
511
  expect(config).to be_expecting_with_rspec
433
512
  end
434
513
 
435
- it "returns false when `expect_with :stdlib` has been configured" do
436
- config.expect_with :stdlib
514
+ it "returns false when `expect_with :minitest` has been configured" do
515
+ config.expect_with :minitest
437
516
  expect(config).not_to be_expecting_with_rspec
438
517
  end
439
518
  end
@@ -576,8 +655,20 @@ module RSpec::Core
576
655
  end
577
656
  end
578
657
 
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
+
579
668
  %w[pattern= filename_pattern=].each do |setter|
580
669
  describe "##{setter}" do
670
+ before { allow_deprecation } if setter == "filename_pattern="
671
+
581
672
  context "with single pattern" do
582
673
  before { config.send(setter, "**/*_foo.rb") }
583
674
  it "loads files following pattern" do
@@ -793,8 +884,53 @@ module RSpec::Core
793
884
  end
794
885
  end
795
886
 
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
+
796
925
  %w[color color_enabled].each do |color_option|
797
926
  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
+
798
934
  context "given true" do
799
935
  before { config.send "#{color_option}=", true }
800
936
 
@@ -953,7 +1089,7 @@ module RSpec::Core
953
1089
  end
954
1090
 
955
1091
  it "requires a formatter file based on its fully qualified name" do
956
- config.should_receive(:require).with('rspec/custom_formatter') do
1092
+ config.formatter_loader.should_receive(:require).with('rspec/custom_formatter') do
957
1093
  stub_const("RSpec::CustomFormatter", Class.new(Formatters::BaseFormatter))
958
1094
  end
959
1095
  config.add_formatter "RSpec::CustomFormatter"
@@ -961,7 +1097,7 @@ module RSpec::Core
961
1097
  end
962
1098
 
963
1099
  it "raises NameError if class is unresolvable" do
964
- config.should_receive(:require).with('rspec/custom_formatter3')
1100
+ config.formatter_loader.should_receive(:require).with('rspec/custom_formatter3')
965
1101
  expect(lambda { config.add_formatter "RSpec::CustomFormatter3" }).to raise_error(NameError)
966
1102
  end
967
1103
 
@@ -975,13 +1111,39 @@ module RSpec::Core
975
1111
  expect(config.formatters.first).to be_an_instance_of Formatters::DocumentationFormatter
976
1112
  end
977
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
+
978
1125
  context "with a 2nd arg defining the output" do
1126
+ let(:path) { File.join(Dir.tmpdir, 'output.txt') }
1127
+
979
1128
  it "creates a file at that path and sets it as the output" do
980
- path = File.join(Dir.tmpdir, 'output.txt')
981
1129
  config.add_formatter('doc', path)
982
1130
  expect(config.formatters.first.output).to be_a(File)
983
1131
  expect(config.formatters.first.output.path).to eq(path)
984
1132
  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
985
1147
  end
986
1148
  end
987
1149
 
@@ -1011,6 +1173,18 @@ module RSpec::Core
1011
1173
  expect(config.inclusion_filter[:foo]).to be(true)
1012
1174
  expect(config.inclusion_filter[:bar]).to be(false)
1013
1175
  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
1014
1188
  end
1015
1189
 
1016
1190
  describe "#filter_run_excluding" do
@@ -1172,7 +1346,7 @@ module RSpec::Core
1172
1346
  RSpec.stub(:deprecate)
1173
1347
  config = Configuration.new
1174
1348
  config.backtrace_clean_patterns = [/.*/]
1175
- expect(config.backtrace_cleaner.exclude? "this").to be_truthy
1349
+ expect(config.backtrace_formatter.exclude? "this").to be_truthy
1176
1350
  end
1177
1351
  end
1178
1352
 
@@ -1199,33 +1373,40 @@ module RSpec::Core
1199
1373
  it "can be appended to" do
1200
1374
  config = Configuration.new
1201
1375
  config.backtrace_clean_patterns << /.*/
1202
- expect(config.backtrace_cleaner.exclude? "this").to be_truthy
1376
+ expect(config.backtrace_formatter.exclude? "this").to be_truthy
1203
1377
  end
1204
1378
  end
1205
1379
 
1206
- describe ".backtrace_cleaner#exclude? defaults" do
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
+
1207
1388
  it "returns true for rspec files" do
1208
- expect(config.backtrace_cleaner.exclude?("lib/rspec/core.rb")).to be_truthy
1389
+ expect(config.backtrace_formatter.exclude?("lib/rspec/core.rb")).to be_truthy
1209
1390
  end
1210
1391
 
1211
1392
  it "returns true for spec_helper" do
1212
- expect(config.backtrace_cleaner.exclude?("spec/spec_helper.rb")).to be_truthy
1393
+ expect(config.backtrace_formatter.exclude?("spec/spec_helper.rb")).to be_truthy
1213
1394
  end
1214
1395
 
1215
1396
  it "returns true for java files (for JRuby)" do
1216
- expect(config.backtrace_cleaner.exclude?("org/jruby/RubyArray.java:2336")).to be_truthy
1397
+ expect(config.backtrace_formatter.exclude?("org/jruby/RubyArray.java:2336")).to be_truthy
1217
1398
  end
1218
1399
 
1219
1400
  it "returns true for files within installed gems" do
1220
- expect(config.backtrace_cleaner.exclude?('ruby-1.8.7-p334/gems/mygem-2.3.0/lib/mygem.rb')).to be_truthy
1401
+ expect(config.backtrace_formatter.exclude?('ruby-1.8.7-p334/gems/mygem-2.3.0/lib/mygem.rb')).to be_truthy
1221
1402
  end
1222
1403
 
1223
1404
  it "returns false for files in projects containing 'gems' in the name" do
1224
- expect(config.backtrace_cleaner.exclude?('code/my-gems-plugin/lib/plugin.rb')).to be_falsey
1405
+ expect(config.backtrace_formatter.exclude?('code/my-gems-plugin/lib/plugin.rb')).to be_falsey
1225
1406
  end
1226
1407
 
1227
1408
  it "returns false for something in the current working directory" do
1228
- expect(config.backtrace_cleaner.exclude?("#{Dir.getwd}/arbitrary")).to be_falsey
1409
+ expect(config.backtrace_formatter.exclude?("#{Dir.getwd}/arbitrary")).to be_falsey
1229
1410
  end
1230
1411
  end
1231
1412
 
@@ -1801,7 +1982,12 @@ module RSpec::Core
1801
1982
  expect($VERBOSE).to eq false
1802
1983
  end
1803
1984
 
1804
- it 'returns the verbosity setting' do
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/)
1805
1991
  expect(config.warnings).to eq $VERBOSE
1806
1992
  end
1807
1993
 
@@ -292,7 +292,7 @@ module RSpec::Core
292
292
  context "and a string in an inner group" do
293
293
  it "is the top level constant" do
294
294
  group = ExampleGroup.describe(String) do
295
- describe :symbol do
295
+ describe "some string" do
296
296
  example "described_class is String" do
297
297
  expect(described_class).to eq(String)
298
298
  end
@@ -308,7 +308,7 @@ module RSpec::Core
308
308
  group = ExampleGroup.describe(String) do
309
309
  described_class
310
310
  metadata[:example_group][:described_class] = Object
311
- describe :symbol do
311
+ describe "inner" do
312
312
  example "described_class is Object" do
313
313
  expect(described_class).to eq(Object)
314
314
  end
@@ -332,6 +332,63 @@ module RSpec::Core
332
332
 
333
333
  expect(group.run).to be_truthy, "expected examples in group to pass"
334
334
  end
335
+
336
+ def capture_deprecation_options
337
+ warn_opts = nil
338
+ allow(RSpec.configuration.reporter).to receive(:deprecation) do |opts|
339
+ warn_opts = opts
340
+ end
341
+
342
+ yield
343
+
344
+ warn_opts
345
+ end
346
+
347
+ it "prints a deprecation warning since the semantics are changing in RSpec 3" do
348
+ warn_opts = capture_deprecation_options do
349
+ ExampleGroup.describe(String) do
350
+ describe Array do
351
+ example { described_class }
352
+ end
353
+ end.run
354
+ end
355
+
356
+ expect(warn_opts[:message]).to include("#{__FILE__}:#{__LINE__ - 5}")
357
+ expect(warn_opts[:message]).to include("described_class")
358
+ end
359
+
360
+ it "prints a deprecation even when `described_class` has already been referenced in the outer group" do
361
+ warn_opts = capture_deprecation_options do
362
+ outer_dc = inner_dc = nil
363
+ ExampleGroup.describe(String) do
364
+ outer_dc = described_class
365
+ describe Array do
366
+ example { inner_dc = described_class }
367
+ end
368
+ end.run
369
+
370
+ expect(outer_dc).to eq(String)
371
+ expect(inner_dc).to eq(String)
372
+ end
373
+
374
+ expect(warn_opts[:message]).to include("#{__FILE__}:#{__LINE__ - 8}")
375
+ expect(warn_opts[:message]).to include("described_class")
376
+ end
377
+
378
+ it "does not print a deprecation warning when the inner example group has no description args" do
379
+ dc = :unset
380
+ deprecations = []
381
+ allow(RSpec).to receive(:warn_deprecation) { |msg| deprecations << msg }
382
+
383
+ ExampleGroup.describe(String) do
384
+ describe do
385
+ example { dc = described_class }
386
+ end
387
+ end.run
388
+
389
+ expect(dc).to be(String)
390
+ expect(deprecations).to eq([])
391
+ end
335
392
  end
336
393
 
337
394
  context "for `describe(SomeClass)` within a `describe 'some string' group" do
@@ -677,6 +734,7 @@ module RSpec::Core
677
734
  it "has access to example options within before(:each)" do
678
735
  group = ExampleGroup.describe
679
736
  option = nil
737
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /options/)
680
738
  group.before(:each) {|ex| option = ex.options[:data] }
681
739
  group.example("no-op", :data => :sample) { }
682
740
  group.run
@@ -686,6 +744,7 @@ module RSpec::Core
686
744
  it "has access to example options within after(:each)" do
687
745
  group = ExampleGroup.describe
688
746
  option = nil
747
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /options/)
689
748
  group.after(:each) {|ex| option = ex.options[:data] }
690
749
  group.example("no-op", :data => :sample) { }
691
750
  group.run
@@ -693,19 +752,37 @@ module RSpec::Core
693
752
  end
694
753
  end
695
754
 
755
+ context 'skip in metadata' do
756
+ let(:group) { ExampleGroup.describe do
757
+ it 'is skipped', :skip => 'skip this' do
758
+ end
759
+ end
760
+ }
761
+
762
+ before { group.run }
763
+
764
+ it 'generates a pending example' do
765
+ expect(group.examples.first).to be_pending
766
+ end
767
+
768
+ it 'sets the pending message' do
769
+ expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq('skip this')
770
+ end
771
+ end
772
+
696
773
  %w[pending skip].each do |method_name|
697
774
  describe ".#{method_name}" do
698
775
  let(:group) { ExampleGroup.describe.tap {|x|
699
776
  x.send(method_name, "is pending") { }
700
777
  }}
701
778
 
779
+ before { group.run }
780
+
702
781
  it "generates a pending example" do
703
- group.run
704
782
  expect(group.examples.first).to be_pending
705
783
  end
706
784
 
707
785
  it "sets the pending message" do
708
- group.run
709
786
  expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
710
787
  end
711
788
  end
@@ -717,13 +794,13 @@ module RSpec::Core
717
794
  x.send(method_name, "is pending") { }
718
795
  }}
719
796
 
797
+ before { group.run }
798
+
720
799
  it "generates a pending example" do
721
- group.run
722
800
  expect(group.examples.first).to be_pending
723
801
  end
724
802
 
725
803
  it "sets the pending message" do
726
- group.run
727
804
  expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq("Temporarily disabled with #{method_name}")
728
805
  end
729
806
  end
@@ -1223,5 +1300,38 @@ module RSpec::Core
1223
1300
  end.to raise_error(ArgumentError,%q|Could not find shared examples "shared stuff"|)
1224
1301
  end
1225
1302
  end
1303
+
1304
+ describe "deprecated methods" do
1305
+ specify ".describes is deprecated" do
1306
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /describes/)
1307
+ expect(self.class.describes).to eq(self.class.described_class)
1308
+ end
1309
+
1310
+ specify ".display_name is deprecated" do
1311
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /display_name/)
1312
+ expect(self.class.display_name).to eq(self.class.description)
1313
+ end
1314
+
1315
+ specify ".alias_it_behaves_like_to is deprecated" do
1316
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /alias_it_behaves_like_to/)
1317
+ expect {
1318
+ ExampleGroup.alias_it_behaves_like_to(:it_does_something, "it does something")
1319
+ }.to change { ExampleGroup.respond_to?(:it_does_something) }.from(false).to(true)
1320
+ end
1321
+
1322
+ specify ".alias_example_to is deprecated" do
1323
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /alias_example_to/)
1324
+ expect {
1325
+ ExampleGroup.alias_example_to(:an_example)
1326
+ }.to change { ExampleGroup.respond_to?(:an_example) }.from(false).to(true)
1327
+ end
1328
+
1329
+ specify ".focused is deprecated" do
1330
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /focused/)
1331
+ ExampleGroup.describe("group") do
1332
+ focused("example") { }
1333
+ end
1334
+ end
1335
+ end
1226
1336
  end
1227
1337
  end