From 7f77f08123f5111330db32b959d5f198e4b6b351 Mon Sep 17 00:00:00 2001 From: AI-Mozi Date: Mon, 15 May 2023 14:37:29 +0200 Subject: [PATCH] Add specs for `Module#refinements` and `Refinement#refined_class` --- core/module/refinements_spec.rb | 22 ++++++++++++++++++++++ core/refinement/refined_class_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 core/module/refinements_spec.rb create mode 100644 core/refinement/refined_class_spec.rb diff --git a/core/module/refinements_spec.rb b/core/module/refinements_spec.rb new file mode 100644 index 000000000..15b69aa20 --- /dev/null +++ b/core/module/refinements_spec.rb @@ -0,0 +1,22 @@ +require_relative '../../spec_helper' + +describe "Module#refinements" do + ruby_version_is "3.2" do + it "returns list of classes redefined in module" do + refined_integer = nil + refined_string = nil + + m = Module.new do + refine Integer do + refined_integer = self + end + + refine String do + refined_string = self + end + end + + m.refinements.should == [refined_integer, refined_string] + 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..3682e7b6a --- /dev/null +++ b/core/refinement/refined_class_spec.rb @@ -0,0 +1,20 @@ +require_relative '../../spec_helper' + +describe "Refinement#refined_class" do + ruby_version_is "3.2" do + it "returns the class refined by the receiver" do + r = Module.new do + refine Integer do + refined_integer = self + end + + refine String do + refined_string = self + end + end.refinements + + r[0].refined_class.should == Integer + r[1].refined_class.should == String + end + end +end