| | 431 | |
|---|
| | 432 | describe 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 |
|---|
| | 459 | end |
|---|