Updated MSpec source to 46e80081.
[rbx.git] / spec / subtend / call_super_spec.rb
blob0bfee2192bce9506da2ddcb00bd57d1821b7bfc1
1 require File.dirname(__FILE__) + '/../spec_helper'
2 require File.dirname(__FILE__) + '/subtend_helper'
4 compile_extension('subtend_call_super')
5 require File.dirname(__FILE__) + '/ext/subtend_call_super'
7 describe "SubtendCallSuper" do
8   before :each do
9     @s = SubtendCallSuper.new
10   end
12   class TheSuper
13     # Set an instance variable to ensure we are doing rb_call_super on this
14     # instance.
15     def initialize(value)
16       @value = value.to_i
17     end
19     def a_method
20       return @value
21     end
22   end
24   class TheSub < TheSuper
25   end
27   it "rb_call_super should call the method in the superclass" do
28     instance = TheSub.new(1)
29     instance.a_method.should == 1
30     @s.override_method(TheSub) # Override the method, use rb_call_super
31     instance.a_method.should == 2
32   end
34   it "should create a subclass and create a new instance" do
35     @s.test_subclass_and_instantiation().should == true
36     (instance = ModuleTest::ClassSuper.new()).should_not == nil
37     (instance = ModuleTest::ClassSub.new()).should_not == nil
38   end
39 end