1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
module Contracts
RSpec.describe Support do
describe "eigenclass?" do
it "is falsey for non-singleton classes" do
expect(Contracts::Support.eigenclass? String).to be_falsey
end
it "is truthy for singleton classes" do
singleton_class = String.instance_exec { class << self; self; end }
expect(Contracts::Support.eigenclass? singleton_class).to be_truthy
end
end
describe "eigenclass_of" do
it "returns the eigenclass of a given object" do
singleton_class = String.instance_exec { class << self; self; end }
expect(Contracts::Support.eigenclass_of String).to eq singleton_class
end
end
end
end
|