Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / spec / spec / dsl / description_spec.rb
blob5974528120c0ca8d82ea7350ab27ce39aafa81b9
1 require File.dirname(__FILE__) + '/../../spec_helper'
3 module Spec
4   module DSL
5     describe Description, " constructed with a single String" do 
6       before(:each) {@description = Description.new("abc")}
7       
8       it "should provide that string as its name" do
9         @description.description.should == "abc"
10       end
11       it "should provide nil as its type" do
12         @description.described_type.should be_nil
13       end
14       it "should respond to []" do
15         @description[:key].should be_nil
16       end
17       it "should respond to []=" do
18         @description[:key] = :value
19         @description[:key].should == :value
20       end
21       it "should return for == when value matches description" do
22         @description.should == "abc"
23       end
24       it "should return for == when value is other description that matches description" do
25         @description.should == Description.new("abc")
26       end
27     end
28     
29     describe Description, " constructed with a Type" do 
30       before(:each) {@description = Description.new(Behaviour)}
32       it "should provide a String representation of that type (fully qualified) as its name" do
33         @description.description.should == "Spec::DSL::Behaviour"
34       end
35       it "should provide that type (fully qualified) as its type" do
36         @description.described_type.should == Spec::DSL::Behaviour
37       end
38     end
39     
40     describe Description, " constructed with a Type and a String" do 
41       before(:each) {@description = Description.new(Behaviour, " behaving")}
42       
43       it "should include the type and second String in its name" do
44         @description.description.should == "Spec::DSL::Behaviour behaving"
45       end
46       it "should provide that type (fully qualified) as its type" do
47         @description.described_type.should == Spec::DSL::Behaviour
48       end
49     end
51     describe Description, "constructed with a Type and a String not starting with a space" do 
52       before(:each) {@description = Description.new(Behaviour, "behaving")}
54       it "should include the type and second String with a space in its name" do
55         @description.description.should == "Spec::DSL::Behaviour behaving"
56       end
57     end
59     describe Description, "constructed with a Type and a String starting with a ." do 
60       before(:each) {@description = Description.new(Behaviour, ".behaving")}
62       it "should include the type and second String with a space in its name" do
63         @description.description.should == "Spec::DSL::Behaviour.behaving"
64       end
65     end
67     describe Description, "constructed with a Type and a String starting with a #" do 
68       before(:each) {@description = Description.new(Behaviour, "#behaving")}
70       it "should include the type and second String with a space in its name" do
71         @description.description.should == "Spec::DSL::Behaviour#behaving"
72       end
73     end
75     describe Description, " constructed with options" do before(:each) {@description = Description.new(Behaviour, :a => "b")}
76       it "should provide its options" do
77         @description[:a].should == "b"
78       end
79     end
80   end
81 end