-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for
Module#refinements
and Refinement#refined_class
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |