lib/minitest/spec.rb in minitest-5.25.1 vs lib/minitest/spec.rb in minitest-5.25.2
- old
+ new
@@ -79,17 +79,18 @@
#
# For more information about expectations, see Minitest::Expectations.
def describe desc, *additional_desc, &block # :doc:
stack = Minitest::Spec.describe_stack
- name = [stack.last, desc, *additional_desc].compact.join("::")
- sclas = stack.last || if Class === self && kind_of?(Minitest::Spec::DSL) then
- self
- else
- Minitest::Spec.spec_type desc, *additional_desc
- end
+ is_spec_class = Class === self && kind_of?(Minitest::Spec::DSL)
+ name = [stack.last, desc, *additional_desc]
+ name.prepend self if stack.empty? && is_spec_class
+ sclas =
+ stack.last \
+ || (is_spec_class && self) \
+ || Minitest::Spec.spec_type(desc, *additional_desc)
- cls = sclas.create name, desc
+ cls = sclas.create name.compact.join("::"), desc
stack.push cls
cls.class_eval(&block)
stack.pop
cls