rspec-core 3.13.5 → 4.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 (49) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/Changelog.md +56 -1
  4. data/LICENSE.md +2 -2
  5. data/README.md +33 -44
  6. data/lib/rspec/core/bisect/example_minimizer.rb +3 -3
  7. data/lib/rspec/core/bisect/fork_runner.rb +0 -6
  8. data/lib/rspec/core/bisect/shell_command.rb +2 -0
  9. data/lib/rspec/core/bisect/shell_runner.rb +2 -25
  10. data/lib/rspec/core/bisect/utilities.rb +3 -7
  11. data/lib/rspec/core/configuration.rb +128 -330
  12. data/lib/rspec/core/configuration_options.rb +4 -16
  13. data/lib/rspec/core/drb.rb +0 -5
  14. data/lib/rspec/core/dsl.rb +3 -48
  15. data/lib/rspec/core/example.rb +5 -41
  16. data/lib/rspec/core/example_group.rb +36 -75
  17. data/lib/rspec/core/filter_manager.rb +2 -11
  18. data/lib/rspec/core/formatters/deprecation_formatter.rb +4 -4
  19. data/lib/rspec/core/formatters/exception_presenter.rb +30 -60
  20. data/lib/rspec/core/formatters/helpers.rb +1 -1
  21. data/lib/rspec/core/formatters/html_printer.rb +8 -7
  22. data/lib/rspec/core/formatters/html_snippet_extractor.rb +0 -4
  23. data/lib/rspec/core/formatters/profile_formatter.rb +2 -2
  24. data/lib/rspec/core/formatters/snippet_extractor.rb +3 -1
  25. data/lib/rspec/core/formatters/syntax_highlighter.rb +2 -0
  26. data/lib/rspec/core/formatters.rb +4 -8
  27. data/lib/rspec/core/hooks.rb +24 -45
  28. data/lib/rspec/core/memoized_helpers.rb +30 -120
  29. data/lib/rspec/core/metadata.rb +8 -216
  30. data/lib/rspec/core/metadata_filter.rb +15 -69
  31. data/lib/rspec/core/minitest_assertions_adapter.rb +2 -2
  32. data/lib/rspec/core/mocking_adapters/mocha.rb +2 -31
  33. data/lib/rspec/core/notifications.rb +4 -16
  34. data/lib/rspec/core/option_parser.rb +6 -14
  35. data/lib/rspec/core/ordering.rb +5 -6
  36. data/lib/rspec/core/output_wrapper.rb +2 -2
  37. data/lib/rspec/core/pending.rb +1 -9
  38. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +14 -31
  39. data/lib/rspec/core/rake_task.rb +6 -7
  40. data/lib/rspec/core/shared_example_group.rb +7 -82
  41. data/lib/rspec/core/shell_escape.rb +2 -0
  42. data/lib/rspec/core/test_unit_assertions_adapter.rb +4 -17
  43. data/lib/rspec/core/version.rb +1 -1
  44. data/lib/rspec/core/world.rb +8 -23
  45. data/lib/rspec/core.rb +1 -22
  46. data.tar.gz.sig +0 -0
  47. metadata +24 -25
  48. metadata.gz.sig +0 -0
  49. data/lib/rspec/core/flat_map.rb +0 -20
@@ -31,7 +31,7 @@ module RSpec
31
31
 
32
32
  if duration > 60
33
33
  minutes = (duration.round / 60).to_i
34
- seconds = (duration - minutes * 60)
34
+ seconds = (duration - (minutes * 60))
35
35
 
36
36
  "#{pluralize(minutes, 'minute')} #{pluralize(format_seconds(seconds, precision), 'second')}"
37
37
  else
@@ -6,6 +6,7 @@ module RSpec
6
6
  # @private
7
7
  class HtmlPrinter
8
8
  include ERB::Util # For the #h method.
9
+
9
10
  def initialize(output)
10
11
  @output = output
11
12
  end
@@ -29,8 +30,8 @@ module RSpec
29
30
  def print_example_passed(description, run_time)
30
31
  formatted_run_time = "%.5f" % run_time
31
32
  @output.puts " <dd class=\"example passed\">" \
32
- "<span class=\"passed_spec_name\">#{h(description)}</span>" \
33
- "<span class='duration'>#{formatted_run_time}s</span></dd>"
33
+ "<span class=\"passed_spec_name\">#{h(description)}</span>" \
34
+ "<span class='duration'>#{formatted_run_time}s</span></dd>"
34
35
  end
35
36
 
36
37
  def print_example_failed(pending_fixed, description, run_time, failure_id,
@@ -52,8 +53,8 @@ module RSpec
52
53
 
53
54
  def print_example_pending(description, pending_message)
54
55
  @output.puts " <dd class=\"example not_implemented\">" \
55
- "<span class=\"not_implemented_spec_name\">#{h(description)} " \
56
- "(PENDING: #{h(pending_message)})</span></dd>"
56
+ "<span class=\"not_implemented_spec_name\">#{h(description)} " \
57
+ "(PENDING: #{h(pending_message)})</span></dd>"
57
58
  end
58
59
 
59
60
  def print_summary(duration, example_count, failure_count, pending_count)
@@ -66,10 +67,10 @@ module RSpec
66
67
  formatted_duration = "%.5f" % duration
67
68
 
68
69
  @output.puts "<script type=\"text/javascript\">" \
69
- "document.getElementById('duration').innerHTML = \"Finished in " \
70
- "<strong>#{formatted_duration} seconds</strong>\";</script>"
70
+ "document.getElementById('duration').innerHTML = \"Finished in " \
71
+ "<strong>#{formatted_duration} seconds</strong>\";</script>"
71
72
  @output.puts "<script type=\"text/javascript\">" \
72
- "document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
73
+ "document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
73
74
  @output.puts "</div>"
74
75
  @output.puts "</div>"
75
76
  @output.puts "</body>"
@@ -92,10 +92,6 @@ module RSpec
92
92
  else
93
93
  "# Couldn't get snippet for #{file}"
94
94
  end
95
- rescue SecurityError
96
- # :nocov: - SecurityError is no longer produced starting in ruby 2.7
97
- "# Couldn't get snippet for #{file}"
98
- # :nocov:
99
95
  end
100
96
 
101
97
  # @api private
@@ -31,8 +31,8 @@ module RSpec
31
31
 
32
32
  def dump_profile_slowest_examples(profile)
33
33
  @output.puts "\nTop #{profile.slowest_examples.size} slowest " \
34
- "examples (#{Helpers.format_seconds(profile.slow_duration)} " \
35
- "seconds, #{profile.percentage}% of total time):\n"
34
+ "examples (#{Helpers.format_seconds(profile.slow_duration)} " \
35
+ "seconds, #{profile.percentage}% of total time):\n"
36
36
 
37
37
  profile.slowest_examples.each do |example|
38
38
  @output.puts " #{example.full_description}"
@@ -1,3 +1,5 @@
1
+ RSpec::Support.require_rspec_support 'ruby_features'
2
+
1
3
  module RSpec
2
4
  module Core
3
5
  module Formatters
@@ -68,7 +70,7 @@ module RSpec
68
70
  end
69
71
 
70
72
  def unclosed_tokens_in_line_range(line_range)
71
- tokens = FlatMap.flat_map(line_range) do |line_number|
73
+ tokens = line_range.flat_map do |line_number|
72
74
  source.tokens_by_line_number[line_number]
73
75
  end
74
76
 
@@ -1,3 +1,5 @@
1
+ RSpec::Support.require_rspec_support 'ruby_features'
2
+
1
3
  module RSpec
2
4
  module Core
3
5
  module Formatters
@@ -160,19 +160,15 @@ module RSpec::Core::Formatters
160
160
  formatter = RSpec::LegacyFormatters.load_formatter formatter_class, *args
161
161
  register formatter, formatter.notifications
162
162
  else
163
- call_site = "Formatter added at: #{::RSpec::CallerFilter.first_non_rspec_line}"
164
-
165
- RSpec.warn_deprecation <<-WARNING.gsub(/\s*\|/, ' ')
163
+ raise ArgumentError, <<-ERROR.gsub(/\s*\|/, ' ')
166
164
  |The #{formatter_class} formatter uses the deprecated formatter
167
- |interface not supported directly by RSpec 3.
165
+ |interface not supported directly by RSpec 4.
168
166
  |
169
167
  |To continue to use this formatter you must install the
170
168
  |`rspec-legacy_formatters` gem, which provides support
171
169
  |for legacy formatters or upgrade the formatter to a
172
170
  |compatible version.
173
- |
174
- |#{call_site}
175
- WARNING
171
+ ERROR
176
172
  end
177
173
  end
178
174
 
@@ -258,7 +254,7 @@ module RSpec::Core::Formatters
258
254
  # activesupport/lib/active_support/inflector/methods.rb, line 48
259
255
  def underscore(camel_cased_word)
260
256
  word = camel_cased_word.to_s.dup
261
- word.gsub!(/::/, '/')
257
+ word.gsub!('::', '/')
262
258
  word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
263
259
  word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
264
260
  word.tr!("-", "_")
@@ -112,9 +112,9 @@ module RSpec
112
112
  #
113
113
  # ### Warning: implicit before blocks
114
114
  #
115
- # `before` hooks can also be declared in shared contexts which get
116
- # included implicitly either by you or by extension libraries. Since
117
- # RSpec runs these in the order in which they are declared within each
115
+ # `before` hooks can also be declared in configuration-level shared contexts
116
+ # which get included implicitly either by you or by extension libraries.
117
+ # Since RSpec runs these in the order in which they are declared within each
118
118
  # scope, load order matters, and can lead to confusing results when one
119
119
  # before block depends on state that is prepared in another before block
120
120
  # that gets run later.
@@ -393,16 +393,8 @@ module RSpec
393
393
  "#{hook_description} did not execute the example")
394
394
  end
395
395
 
396
- if Proc.method_defined?(:source_location)
397
- def hook_description
398
- "around hook at #{Metadata.relative_path(block.source_location.join(':'))}"
399
- end
400
- else # for 1.8.7
401
- # :nocov:
402
- def hook_description
403
- "around hook"
404
- end
405
- # :nocov:
396
+ def hook_description
397
+ "around hook at #{Metadata.relative_path(block.source_location.take(2).join(':'))}"
406
398
  end
407
399
  end
408
400
 
@@ -450,18 +442,13 @@ module RSpec
450
442
  scope, options = scope_and_options_from(*args)
451
443
 
452
444
  if scope == :suite
453
- # TODO: consider making this an error in RSpec 4. For SemVer reasons,
454
- # we are only warning in RSpec 3.
455
- RSpec.warn_with "WARNING: `#{position}(:suite)` hooks are only supported on " \
456
- "the RSpec configuration object. This " \
457
- "`#{position}(:suite)` hook, registered on an example " \
458
- "group, will be ignored."
459
- return
445
+ raise ArgumentError, "`#{position}(:suite)` hooks are only " \
446
+ "supported on the RSpec configuration object. This " \
447
+ "`#{position}(:suite)` hook, registered on an example " \
448
+ "group, will be ignored."
460
449
  elsif scope == :context && position == :around
461
- # TODO: consider making this an error in RSpec 4. For SemVer reasons,
462
- # we are only warning in RSpec 3.
463
- RSpec.warn_with "WARNING: `around(:context)` hooks are not supported and " \
464
- "behave like `around(:example)`."
450
+ raise ArgumentError, "`around(:context)` hooks are not supported " \
451
+ "and behave like `around(:example)`."
465
452
  end
466
453
 
467
454
  hook = HOOK_TYPES[position][scope].new(block, options)
@@ -553,18 +540,18 @@ module RSpec
553
540
  def ensure_hooks_initialized_for(position, scope)
554
541
  if position == :before
555
542
  if scope == :example
556
- @before_example_hooks ||= @filterable_item_repo_class.new(:all?)
543
+ @before_example_hooks ||= @filterable_item_repo_class.new
557
544
  else
558
- @before_context_hooks ||= @filterable_item_repo_class.new(:all?)
545
+ @before_context_hooks ||= @filterable_item_repo_class.new
559
546
  end
560
547
  elsif position == :after
561
548
  if scope == :example
562
- @after_example_hooks ||= @filterable_item_repo_class.new(:all?)
549
+ @after_example_hooks ||= @filterable_item_repo_class.new
563
550
  else
564
- @after_context_hooks ||= @filterable_item_repo_class.new(:all?)
551
+ @after_context_hooks ||= @filterable_item_repo_class.new
565
552
  end
566
553
  else # around
567
- @around_example_hooks ||= @filterable_item_repo_class.new(:all?)
554
+ @around_example_hooks ||= @filterable_item_repo_class.new
568
555
  end
569
556
  end
570
557
 
@@ -572,7 +559,7 @@ module RSpec
572
559
  hooks_to_process = globals.processable_hooks_for(position, scope, host)
573
560
  return if hooks_to_process.empty?
574
561
 
575
- hooks_to_process -= FlatMap.flat_map(parent_groups) do |group|
562
+ hooks_to_process -= parent_groups.flat_map do |group|
576
563
  group.hooks.all_hooks_for(position, scope)
577
564
  end
578
565
  return if hooks_to_process.empty?
@@ -584,7 +571,7 @@ module RSpec
584
571
  def scope_and_options_from(*args)
585
572
  return :suite if args.first == :suite
586
573
  scope = extract_scope_from(args)
587
- meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
574
+ meta = Metadata.build_hash_from(args)
588
575
  return scope, meta
589
576
  end
590
577
 
@@ -593,9 +580,9 @@ module RSpec
593
580
  normalized_scope_for(args.shift)
594
581
  elsif args.any? { |a| a.is_a?(Symbol) }
595
582
  error_message = "You must explicitly give a scope " \
596
- "(#{SCOPES.join(", ")}) or scope alias " \
597
- "(#{SCOPE_ALIASES.keys.join(", ")}) when using symbols as " \
598
- "metadata for a hook."
583
+ "(#{SCOPES.join(", ")}) or scope alias " \
584
+ "(#{SCOPE_ALIASES.keys.join(", ")}) when using symbols as " \
585
+ "metadata for a hook."
599
586
  raise ArgumentError.new error_message
600
587
  else
601
588
  :example
@@ -617,7 +604,7 @@ module RSpec
617
604
  end
618
605
 
619
606
  def run_around_example_hooks_for(example)
620
- hooks = FlatMap.flat_map(owner_parent_groups) do |group|
607
+ hooks = owner_parent_groups.flat_map do |group|
621
608
  group.hooks.matching_hooks_for(:around, :example, example)
622
609
  end
623
610
 
@@ -629,16 +616,8 @@ module RSpec
629
616
  end.call
630
617
  end
631
618
 
632
- if respond_to?(:singleton_class) && singleton_class.ancestors.include?(singleton_class)
633
- def owner_parent_groups
634
- @owner.parent_groups
635
- end
636
- else # Ruby < 2.1 (see https://bugs.ruby-lang.org/issues/8035)
637
- # :nocov:
638
- def owner_parent_groups
639
- @owner_parent_groups ||= [@owner] + @owner.parent_groups
640
- end
641
- # :nocov:
619
+ def owner_parent_groups
620
+ @owner.parent_groups
642
621
  end
643
622
  end
644
623
  end
@@ -12,8 +12,6 @@ module RSpec
12
12
  #
13
13
  # RSpec.describe Widget do
14
14
  # it { is_expected.to validate_presence_of(:name) }
15
- # # or
16
- # it { should validate_presence_of(:name) }
17
15
  # end
18
16
  #
19
17
  # While the examples below demonstrate how to use `subject`
@@ -25,25 +23,21 @@ module RSpec
25
23
  # # Explicit declaration of subject.
26
24
  # RSpec.describe Person do
27
25
  # subject { Person.new(:birthdate => 19.years.ago) }
28
- # it "should be eligible to vote" do
29
- # subject.should be_eligible_to_vote
30
- # # ^ ^ explicit reference to subject not recommended
26
+ # it "is eligible to vote" do
27
+ # is_expected.to be_eligible_to_vote
31
28
  # end
32
29
  # end
33
30
  #
34
31
  # # Implicit subject => { Person.new }.
35
32
  # RSpec.describe Person do
36
- # it "should be eligible to vote" do
37
- # subject.should be_eligible_to_vote
38
- # # ^ ^ explicit reference to subject not recommended
33
+ # it "is eligible to vote" do
34
+ # is_expected.to be_eligible_to_vote
39
35
  # end
40
36
  # end
41
37
  #
42
38
  # # One-liner syntax - expectation is set on the subject.
43
39
  # RSpec.describe Person do
44
40
  # it { is_expected.to be_eligible_to_vote }
45
- # # or
46
- # it { should be_eligible_to_vote }
47
41
  # end
48
42
  #
49
43
  # @note Because `subject` is designed to create state that is reset
@@ -51,8 +45,6 @@ module RSpec
51
45
  # state that is shared across _all_ examples in an example group,
52
46
  # `subject` is _not_ intended to be used in a `before(:context)` hook.
53
47
  #
54
- # @see #should
55
- # @see #should_not
56
48
  # @see #is_expected
57
49
  def subject
58
50
  __memoized.fetch_or_store(:subject) do
@@ -61,47 +53,6 @@ module RSpec
61
53
  end
62
54
  end
63
55
 
64
- # When `should` is called with no explicit receiver, the call is
65
- # delegated to the object returned by `subject`. Combined with an
66
- # implicit subject this supports very concise expressions.
67
- #
68
- # @example
69
- #
70
- # RSpec.describe Person do
71
- # it { should be_eligible_to_vote }
72
- # end
73
- #
74
- # @see #subject
75
- # @see #is_expected
76
- #
77
- # @note This only works if you are using rspec-expectations.
78
- # @note If you are using RSpec's newer expect-based syntax you may
79
- # want to use `is_expected.to` instead of `should`.
80
- def should(matcher=nil, message=nil)
81
- enforce_value_expectation(matcher, 'should')
82
- RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message)
83
- end
84
-
85
- # Just like `should`, `should_not` delegates to the subject (implicit or
86
- # explicit) of the example group.
87
- #
88
- # @example
89
- #
90
- # RSpec.describe Person do
91
- # it { should_not be_eligible_to_vote }
92
- # end
93
- #
94
- # @see #subject
95
- # @see #is_expected
96
- #
97
- # @note This only works if you are using rspec-expectations.
98
- # @note If you are using RSpec's newer expect-based syntax you may
99
- # want to use `is_expected.to_not` instead of `should_not`.
100
- def should_not(matcher=nil, message=nil)
101
- enforce_value_expectation(matcher, 'should_not')
102
- RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message)
103
- end
104
-
105
56
  # Wraps the `subject` in `expect` to make it the target of an expectation.
106
57
  # Designed to read nicely for one-liners.
107
58
  #
@@ -113,8 +64,6 @@ module RSpec
113
64
  # end
114
65
  #
115
66
  # @see #subject
116
- # @see #should
117
- # @see #should_not
118
67
  #
119
68
  # @note This only works if you are using rspec-expectations.
120
69
  def is_expected
@@ -146,26 +95,6 @@ module RSpec
146
95
  end
147
96
  end
148
97
 
149
- # @private
150
- def enforce_value_expectation(matcher, method_name)
151
- return if matcher_supports_value_expectations?(matcher)
152
-
153
- RSpec.deprecate(
154
- "#{method_name} #{RSpec::Support::ObjectFormatter.format(matcher)}",
155
- :message =>
156
- "The implicit block expectation syntax is deprecated, you should pass " \
157
- "a block to `expect` to use the provided block expectation matcher " \
158
- "(#{RSpec::Support::ObjectFormatter.format(matcher)}), " \
159
- "or the matcher must implement `supports_value_expectations?`."
160
- )
161
- end
162
-
163
- def matcher_supports_value_expectations?(matcher)
164
- matcher.supports_value_expectations?
165
- rescue
166
- true
167
- end
168
-
169
98
  # @private
170
99
  class ThreadsafeMemoized
171
100
  def initialize
@@ -300,7 +229,7 @@ EOS
300
229
  # thing.do_something
301
230
  #
302
231
  # # Second invocation, returns the memoized value.
303
- # thing.should be_something
232
+ # expect(thing).to be_something
304
233
  # end
305
234
  # end
306
235
  def let(name, &block)
@@ -321,7 +250,7 @@ EOS
321
250
  #
322
251
  # Note we do not check ancestor modules (see: `instance_methods(false)`)
323
252
  # as we can override them.
324
- if our_module.instance_methods(false).include?(name)
253
+ if our_module.method_defined?(name, false)
325
254
  our_module.__send__(:remove_method, name)
326
255
  end
327
256
  our_module.__send__(:define_method, name, &block)
@@ -331,7 +260,7 @@ EOS
331
260
  #
332
261
  # Note we do not check ancestor modules (see: `instance_methods(false)`)
333
262
  # as we can override them.
334
- if instance_methods(false).include?(name)
263
+ if method_defined?(name, false)
335
264
  remove_method(name)
336
265
  end
337
266
 
@@ -375,12 +304,12 @@ EOS
375
304
  # let(:thing) { Thing.new }
376
305
  #
377
306
  # it "is not invoked implicitly" do
378
- # Thing.count.should eq(0)
307
+ # expect(Thing.count).to eq(0)
379
308
  # end
380
309
  #
381
310
  # it "can be invoked explicitly" do
382
311
  # thing
383
- # Thing.count.should eq(1)
312
+ # expect(Thing.count).to eq(1)
384
313
  # end
385
314
  # end
386
315
  #
@@ -388,12 +317,12 @@ EOS
388
317
  # let!(:thing) { Thing.new }
389
318
  #
390
319
  # it "is invoked implicitly" do
391
- # Thing.count.should eq(1)
320
+ # expect(Thing.count).to eq(1)
392
321
  # end
393
322
  #
394
323
  # it "returns memoized version on first invocation" do
395
324
  # thing
396
- # Thing.count.should eq(1)
325
+ # expect(Thing.count).to eq(1)
397
326
  # end
398
327
  # end
399
328
  # end
@@ -434,12 +363,10 @@ EOS
434
363
  # subject(:account) { CheckingAccount.new(Money.new(50, :USD)) }
435
364
  # it { is_expected.not_to be_overdrawn }
436
365
  # it "has a balance equal to the starting balance" do
437
- # account.balance.should eq(Money.new(50, :USD))
366
+ # expect(account.balance).to eq(Money.new(50, :USD))
438
367
  # end
439
368
  # end
440
369
  #
441
- # @see MemoizedHelpers#should
442
- # @see MemoizedHelpers#should_not
443
370
  # @see MemoizedHelpers#is_expected
444
371
  def subject(name=nil, &block)
445
372
  if name
@@ -485,12 +412,12 @@ EOS
485
412
  # subject { Thing.new }
486
413
  #
487
414
  # it "is not invoked implicitly" do
488
- # Thing.count.should eq(0)
415
+ # expect(Thing.count).to eq(0)
489
416
  # end
490
417
  #
491
418
  # it "can be invoked explicitly" do
492
419
  # subject
493
- # Thing.count.should eq(1)
420
+ # expect(Thing.count).to eq(1)
494
421
  # end
495
422
  # end
496
423
  #
@@ -498,12 +425,12 @@ EOS
498
425
  # subject!(:thing) { Thing.new }
499
426
  #
500
427
  # it "is invoked implicitly" do
501
- # Thing.count.should eq(1)
428
+ # expect(Thing.count).to eq(1)
502
429
  # end
503
430
  #
504
431
  # it "returns memoized version on first invocation" do
505
432
  # subject
506
- # Thing.count.should eq(1)
433
+ # expect(Thing.count).to eq(1)
507
434
  # end
508
435
  # end
509
436
  # end
@@ -540,39 +467,22 @@ EOS
540
467
 
541
468
  # @private
542
469
  def self.define_helpers_on(example_group)
543
- example_group.__send__(:include, module_for(example_group))
470
+ example_group.include(module_for(example_group))
544
471
  end
545
472
 
546
- if Module.method(:const_defined?).arity == 1 # for 1.8
547
- # @private
548
- #
549
- # Gets the named constant or yields.
550
- # On 1.8, const_defined? / const_get do not take into
551
- # account the inheritance hierarchy.
552
- # :nocov:
553
- def self.get_constant_or_yield(example_group, name)
554
- if example_group.const_defined?(name)
555
- example_group.const_get(name)
556
- else
557
- yield
558
- end
559
- end
560
- # :nocov:
561
- else
562
- # @private
563
- #
564
- # Gets the named constant or yields.
565
- # On 1.9, const_defined? / const_get take into account the
566
- # the inheritance by default, and accept an argument to
567
- # disable this behavior. It's important that we don't
568
- # consider inheritance here; each example group level that
569
- # uses a `let` should get its own `LetDefinitions` module.
570
- def self.get_constant_or_yield(example_group, name)
571
- if example_group.const_defined?(name, (check_ancestors = false))
572
- example_group.const_get(name, check_ancestors)
573
- else
574
- yield
575
- end
473
+ # @private
474
+ #
475
+ # Gets the named constant or yields.
476
+ # const_defined? / const_get take into account the
477
+ # the inheritance by default, and accept an argument to
478
+ # disable this behavior. It's important that we don't
479
+ # consider inheritance here; each example group level that
480
+ # uses a `let` should get its own `LetDefinitions` module.
481
+ def self.get_constant_or_yield(example_group, name)
482
+ if example_group.const_defined?(name, false)
483
+ example_group.const_get(name, false)
484
+ else
485
+ yield
576
486
  end
577
487
  end
578
488
  end