Renamed helpers to correspond to renamed Controller classes.
[merb_radiant.git] / radiant_specs / spec / lib / .svn / text-base / annotatable_spec.rb.svn-base
blobf0745e6c9564ac7171b44349059b6de4334cd0a0
1 require File.dirname(__FILE__) + "/../spec_helper"
3 describe Annotatable, "when included in a class" do
4   class BasicAnnotation
5     include Annotatable
6   end
8   it "should add the annotate method to a class" do
9     BasicAnnotation.should respond_to(:annotate)
10   end
11 end
13 describe Annotatable, "with an annotation added to a class" do
14   class AnnotationsAdded
15     include Annotatable
16     annotate :description
17   end
19   it "should add class accessor methods of the given name for the annotation" do
20     AnnotationsAdded.should respond_to(:description)
21     AnnotationsAdded.should respond_to(:description=)
22   end
24   it "should add instance accessor methods of the given name for the annotation" do
25     @a = AnnotationsAdded.new
26     @a.should respond_to(:description)
27     @a.should respond_to(:description=)
28   end
29   
30   it "should set the value of the annotation when called with a parameter" do
31     AnnotationsAdded.description "test"
32     AnnotationsAdded.description.should == "test"
33   end
34   
35   it "should set the value of the annotation when assigned directly" do
36     AnnotationsAdded.description = "test"
37     AnnotationsAdded.description.should == "test"    
38   end
39   
40   it "should set the value of the annotation when called with a parameter on an instance" do
41     AnnotationsAdded.new.description "test"
42     AnnotationsAdded.description.should == "test"
43   end
44   
45   it "should set the value of the annotation when assigned directly on an instance" do
46     AnnotationsAdded.new.description = "test"
47     AnnotationsAdded.description.should == "test"    
48   end
49 end
51 describe Annotatable, "with annotations defined on a parent class" do
52   class ParentClass
53     include Annotatable
54     annotate :description, :url
55     annotate :another, :inherit => true
56     description "A parent class"
57     url "http://test.host"
58     another "I'm inherited!"
59   end
61   class ChildClass < ParentClass
62   end
64   class OverridingClass < ParentClass
65     another "I'm not inherited!"
66   end
67   
68   it "should receive all parent annotations" do
69     [:description, :url, :another].each do |method|
70       ChildClass.should respond_to(method)
71     end
72   end
73   
74   it "should inherit the parent class' values for inherit annotations" do
75     ChildClass.another.should == "I'm inherited!"
76   end
77   
78   it "should not inherit values for non-inherited annotations" do
79     ChildClass.description.should be_nil
80     ChildClass.url.should be_nil
81   end
82   
83   it "should override inherited values when annotated in a child class" do
84     OverridingClass.another.should == "I'm not inherited!"
85   end
86 end