summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/core/module/const_added_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/ruby/core/module/const_added_spec.rb b/spec/ruby/core/module/const_added_spec.rb
index 4b10dd5963..1b3dad514b 100644
--- a/spec/ruby/core/module/const_added_spec.rb
+++ b/spec/ruby/core/module/const_added_spec.rb
@@ -199,5 +199,25 @@ describe "Module#const_added" do
ScratchPad.recorded.should == [123, 456]
end
+
+ it "for a class defined with the `class` keyword, const_added runs before inherited" do
+ ScratchPad.record []
+
+ mod = Module.new do
+ def self.const_added(_)
+ ScratchPad << :const_added
+ end
+ end
+
+ parent = Class.new do
+ def self.inherited(_)
+ ScratchPad << :inherited
+ end
+ end
+
+ class mod::C < parent; end
+
+ ScratchPad.recorded.should == [:const_added, :inherited]
+ end
end
end