Sha256: 554c3d7f02c6e0e6f06b0148ea75b86da340b7392209840b2e69d39a11ec0689

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Inflector do
  it "should transform words from singular to plural" do
    "post".pluralize.should == "posts"
    "octopus".pluralize.should =="octopi"
    "the blue mailman".pluralize.should == "the blue mailmen"
    "CamelOctopus".pluralize.should == "CamelOctopi"
  end
  
  it "should transform words from plural to singular" do
    "posts".singularize.should == "post"
    "octopi".singularize.should == "octopus"
    "the blue mailmen".singularize.should == "the blue mailman"
    "CamelOctopi".singularize.should == "CamelOctopus"
  end
  
  it "should transform class names to table names" do
    "RawScaledScorer".tableize.should == "raw_scaled_scorers"
    "egg_and_ham".tableize.should == "egg_and_hams"
    "fancyCategory".tableize.should == "fancy_categories"
  end
  
  it "should tranform table names to class names" do
    "egg_and_hams".classify.should == "EggAndHam"
    "post".classify.should == "Post"
  end
  
  it "should create a foreign key name from a class name" do
    "Message".foreign_key.should == "message_id"
    "Message".foreign_key(false).should == "messageid"
    "Admin::Post".foreign_key.should == "post_id"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
merb-0.5.0 spec/merb/core_ext/inflector_spec.rb
merb-0.5.1 spec/merb/core_ext/inflector_spec.rb
merb-0.5.2 spec/merb/core_ext/inflector_spec.rb
merb-0.5.3 spec/merb/core_ext/inflector_spec.rb