diff --git a/core/module/refinements_spec.rb b/core/module/refinements_spec.rb new file mode 100644 index 000000000..93369dc7a --- /dev/null +++ b/core/module/refinements_spec.rb @@ -0,0 +1,33 @@ +require_relative '../../spec_helper' + +describe "Module#refinements" do + ruby_version_is "3.2" do + it "returns refinements defined in a module" do + ScratchPad.record [] + + m1 = Module.new do + refine Integer do + nil + end + end + + m2 = Module.new do + include m1 + + refine String do + ScratchPad << self + end + + refine Array do + ScratchPad << self + end + end + + m2.refinements.should == ScratchPad.recorded + end + + it "returns an empty array if no refinements defined in a module" do + Module.new.refinements.should == [] + end + end +end diff --git a/core/refinement/refined_class_spec.rb b/core/refinement/refined_class_spec.rb new file mode 100644 index 000000000..228db2bac --- /dev/null +++ b/core/refinement/refined_class_spec.rb @@ -0,0 +1,17 @@ +require_relative '../../spec_helper' + +describe "Refinement#refined_class" do + ruby_version_is "3.2" do + it "returns the class refined by the receiver" do + refined_int = nil + + Module.new do + refine Integer do + refined_int = self + end + end + + refined_int.refined_class.should == Integer + end + end +end