A = Class.new do B = 1 end A::B # NameError: uninitialized constant A::B B # => 1

A = Class.new do module B end class C end end A::B # NameError: uninitialized constant A::B A::C # NameError: uninitialized constant A::C

module M A = Class.new do B = 1 end end M::A::B # NameError: uninitialized constant M::A::B M::B # => 1

# spec/a_spec.rb RSpec.describe A do class DummyClass < described_class end it { ... } end # spec/b_spec.rb RSpec.describe A do class DummyClass end it { ... } end

The content of this article is licensed under CC-BY-SA.