2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "Class#initialize" do
|
|
|
|
it "is private" do
|
|
|
|
Class.should have_private_method(:initialize)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises a TypeError when called on already initialized classes" do
|
2019-07-27 06:40:09 -04:00
|
|
|
->{
|
2020-12-20 11:16:26 -05:00
|
|
|
Integer.send :initialize
|
2017-05-07 08:04:49 -04:00
|
|
|
}.should raise_error(TypeError)
|
|
|
|
|
2019-07-27 06:40:09 -04:00
|
|
|
->{
|
2017-05-07 08:04:49 -04:00
|
|
|
Object.send :initialize
|
|
|
|
}.should raise_error(TypeError)
|
|
|
|
end
|
|
|
|
|
|
|
|
# See [redmine:2601]
|
|
|
|
it "raises a TypeError when called on BasicObject" do
|
2019-07-27 06:40:09 -04:00
|
|
|
->{
|
2017-05-07 08:04:49 -04:00
|
|
|
BasicObject.send :initialize
|
|
|
|
}.should raise_error(TypeError)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when given the Class" do
|
|
|
|
before :each do
|
|
|
|
@uninitialized = Class.allocate
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises a TypeError" do
|
2019-07-27 06:40:09 -04:00
|
|
|
->{@uninitialized.send(:initialize, Class)}.should raise_error(TypeError)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|