1 require File.dirname(__FILE__) + '/../spec_helper'
2 require File.dirname(__FILE__) + '/fixtures/private'
4 describe "The private keyword" do
5 it "marks following methods as being private" do
7 a.methods.should_not include("bar")
8 lambda { a.bar }.should raise_error(NoMethodError)
11 b.methods.should_not include("bar")
12 lambda { b.bar }.should raise_error(NoMethodError)
15 it "is overridden when a new class is opened" do
17 c.methods.should include("baz")
19 Private::B::public_class_method1.should == 1
20 Private::B::public_class_method2.should == 2
21 lambda { Private::B::private_class_method1 }.should raise_error(NoMethodError)
24 it "is no longer in effect when the class is closed" do
26 b.methods.should include("foo")
30 it "changes visibility of previously called method" do
38 lambda { f.foo }.should raise_error(NoMethodError)
41 it "changes visiblity of previously called methods with same send/call site" do
52 }.should raise_error(NoMethodError)