Changeset 1021

Show
Ignore:
Timestamp:
11/17/07 16:59:58 (1 year ago)
Author:
e.@brainspl.at
Message:

add some specs for inflector closes #314

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/spec/merb/core_ext_spec.rb

    r784 r1021  
    404404end 
    405405 
    406 describe "extracting options form argruments" do 
     406describe "extracting options from arguments" do 
    407407   
    408408  def the_method(*args) 
     
    429429   
    430430end 
     431 
     432describe Inflector do 
     433  it "should transform words from singular to plural" do 
     434    "post".pluralize.should == "posts" 
     435    "octopus".pluralize.should =="octopi" 
     436    "the blue mailman".pluralize.should == "the blue mailmen" 
     437    "CamelOctopus".pluralize.should == "CamelOctopi" 
     438  end 
     439  it "should transform words from plural to singular" do 
     440    "posts".singularize.should == "post" 
     441    "octopi".singularize.should == "octopus" 
     442    "the blue mailmen".singularize.should == "the blue mailman" 
     443    "CamelOctopi".singularize.should == "CamelOctopus" 
     444  end 
     445  it "should transform class names to table names" do 
     446    "RawScaledScorer".tableize.should == "raw_scaled_scorers" 
     447    "egg_and_ham".tableize.should == "egg_and_hams" 
     448    "fancyCategory".tableize.should == "fancy_categories" 
     449  end 
     450  it "should tranform table names to class names" do 
     451    "egg_and_hams".classify.should == "EggAndHam" 
     452    "post".classify.should == "Post"     
     453  end 
     454  it "should create a foreign key name from a class name" do 
     455    "Message".foreign_key.should == "message_id" 
     456    "Message".foreign_key(false).should == "messageid" 
     457    "Admin::Post".foreign_key.should == "post_id"   
     458  end 
     459end