spec/framework_spec/app/spec/language/metaclass_spec.rb in rhodes-3.1.1 vs spec/framework_spec/app/spec/language/metaclass_spec.rb in rhodes-3.2.0.beta.1
- old
+ new
@@ -1,7 +1,7 @@
-require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../spec_helper'
-require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../fixtures/class'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class', __FILE__)
describe "self in a metaclass body (class << obj)" do
it "is TrueClass for true" do
class << true; self; end.should == TrueClass
end
@@ -25,22 +25,10 @@
it "is a singleton Class instance" do
cls = class << mock('x'); self; end
cls.is_a?(Class).should == true
cls.should_not equal(Object)
end
-
- deviates_on(:rubinius) do
- it "is a MetaClass instance" do
- cls = class << mock('x'); self; end
- cls.is_a?(MetaClass).should == true
- end
-
- it "has the object's class as superclass" do
- cls = class << "blah"; self; end
- cls.superclass.should == String
- end
- end
end
describe "A constant on a metaclass" do
before(:each) do
@object = Object.new
@@ -87,23 +75,36 @@
it "raises a NameError for anonymous_module::CONST" do
@object = Class.new
class << @object
CONST = 100
end
-
+
lambda do
@object::CONST
end.should raise_error(NameError)
end
- it "appears in the metaclass constant list" do
- constants = class << @object; constants; end
- constants.should include(:CONST)
+ ruby_version_is ""..."1.9" do
+ it "appears in the metaclass constant list" do
+ constants = class << @object; constants; end
+ constants.should include("CONST")
+ end
+
+ it "does not appear in the object's class constant list" do
+ @object.class.constants.should_not include("CONST")
+ end
end
- it "does not appear in the object's class constant list" do
- @object.class.constants.should_not include(:CONST)
+ ruby_version_is "1.9" do
+ it "appears in the metaclass constant list" do
+ constants = class << @object; constants; end
+ constants.should include(:CONST)
+ end
+
+ it "does not appear in the object's class constant list" do
+ @object.class.constants.should_not include(:CONST)
+ end
end
it "is not preserved when the object is duped" do
@object = @object.dup
@@ -118,9 +119,5 @@
class << @object
CONST.should_not be_nil
end
end
end
-
-
-
-