Skip to content

Commit

Permalink
Add specs for Module#refinements and Refinement#refined_class
Browse files Browse the repository at this point in the history
  • Loading branch information
AI-Mozi committed May 15, 2023
1 parent 9aa1cbf commit 7f77f08
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/module/refinements_spec.rb
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions core/refinement/refined_class_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7f77f08

Please sign in to comment.