1 require File.dirname(__FILE__) + "/../spec_helper"
7 describe Simpleton, "when included in a class" do
9 it "should add an 'instance' class method" do
10 Dumbo.should respond_to(:instance)
15 describe Simpleton, "when creating or invoking the instance" do
18 Dumbo.class_eval { @instance = nil }
21 it "should return the instance of the class" do
22 Dumbo.instance.should be_instance_of(Dumbo)
25 it "should accept a block and yield the instance" do
27 i.should be_instance_of(Dumbo)
28 i.should == Dumbo.class_eval { @instance }
34 describe Simpleton, "when invoking methods" do
36 it "should delegate missing class methods to the instance" do
37 Dumbo.class_eval { def an_instance_method; :success; end }
38 Dumbo.an_instance_method.should == :success
41 it "should not delegate missing class methods that are not defined on the instance" do
42 lambda { Dumbo.missing_instance_method }.should raise_error(NoMethodError)