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 16, 2023
1 parent 9aa1cbf commit d8f052d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
33 changes: 33 additions & 0 deletions core/module/refinements_spec.rb
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions core/refinement/refined_class_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d8f052d

Please sign in to comment.