@@ -34,40 +34,45 @@ module ::Mock; class Resource; end; end
3434
3535 describe "camelized resource name" do
3636 it "should return a camelized version of the underscored resource name" do
37- config ( :as => "Blog Category " ) . camelized_resource_name . should == "BlogCategory"
37+ config ( :as => "Blog category " ) . camelized_resource_name . should == "BlogCategory"
3838 end
3939 end
4040
41- describe "plural underscored resource name" do
42- before ( :all ) do
43- class ::CandyCane ; end
44- @config = Resource . new ( namespace , CandyCane , { } )
45- end
46-
47- it "should return an underscored and pluralized resource name" do
48- config . plural_underscored_resource_name . should == "candy_canes"
49- end
50- end
51-
5241 describe "resource name" do
5342 it "should return a pretty name" do
5443 config . resource_name . should == "Category"
5544 end
45+
5646 it "should return the plural version" do
5747 config . plural_resource_name . should == "Categories"
5848 end
49+
5950 context "when the :as option is given" do
6051 it "should return the custom name" do
6152 config ( :as => "My Category" ) . resource_name . should == "My Category"
6253 end
6354 end
64- context "I18n" do
65- before do
66- I18n . stub ( :translate ) { 'Categorie' }
55+
56+ describe "I18n integration" do
57+ describe "singular name" do
58+ it "should return the titleized model_name.human" do
59+ Category . model_name . should_receive ( :human ) . and_return "Da category"
60+
61+ config . resource_name . should == "Da Category"
62+ end
6763 end
68- it "should return the plural version defined in the i18n if available" do
69- config . plural_resource_name . should == "Categorie"
64+
65+ describe "plural name" do
66+ it "should return the titleized plural version defined by i18n if available" do
67+ Category . model_name . should_receive ( :underscore ) . and_return "category"
68+ Category . model_name . should_not_receive ( :i18n_key ) # Not implemented in Rails 3.0.0
69+ I18n . should_receive ( :translate! ) .
70+ with ( "activerecord.models.category.other" ) .
71+ and_return ( "Da categories" )
72+ config . plural_resource_name . should == "Da Categories"
73+ end
7074 end
75+
7176 end
7277 end
7378
0 commit comments