2018-03-04 15:09:32 +00:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 12:04:49 +00: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 12:40:09 +02:00
|
|
|
->{
|
2020-12-21 01:16:26 +09:00
|
|
|
Integer.send :initialize
|
2017-05-07 12:04:49 +00:00
|
|
|
}.should raise_error(TypeError)
|
|
|
|
|
2019-07-27 12:40:09 +02:00
|
|
|
->{
|
2017-05-07 12:04:49 +00:00
|
|
|
Object.send :initialize
|
|
|
|
}.should raise_error(TypeError)
|
|
|
|
end
|
|
|
|
|
|
|
|
# See [redmine:2601]
|
|
|
|
it "raises a TypeError when called on BasicObject" do
|
2019-07-27 12:40:09 +02:00
|
|
|
->{
|
2017-05-07 12:04:49 +00: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 12:40:09 +02:00
|
|
|
->{@uninitialized.send(:initialize, Class)}.should raise_error(TypeError)
|
2017-05-07 12:04:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|