diff options
Diffstat (limited to 'spec/ruby/language/class_spec.rb')
-rw-r--r-- | spec/ruby/language/class_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/ruby/language/class_spec.rb b/spec/ruby/language/class_spec.rb index 4ff6e65181..fa30e22c3a 100644 --- a/spec/ruby/language/class_spec.rb +++ b/spec/ruby/language/class_spec.rb @@ -285,6 +285,16 @@ describe "A class definition extending an object (sclass)" do }.should raise_error(TypeError) end + it "raises a TypeError when trying to extend non-Class" do + error_msg = /superclass must be a Class/ + -> { class TestClass < ""; end }.should raise_error(TypeError, error_msg) + -> { class TestClass < 1; end }.should raise_error(TypeError, error_msg) + -> { class TestClass < :symbol; end }.should raise_error(TypeError, error_msg) + -> { class TestClass < mock('o'); end }.should raise_error(TypeError, error_msg) + -> { class TestClass < Module.new; end }.should raise_error(TypeError, error_msg) + -> { class TestClass < BasicObject.new; end }.should raise_error(TypeError, error_msg) + end + ruby_version_is ""..."3.0" do it "allows accessing the block of the original scope" do suppress_warning do |