Sha256: 208f491180880b560ee20ba8b4589c1a3a326bb8bb78d0b6015e954e87c2e6d8

Contents?: true

Size: 1.78 KB

Versions: 9

Compression:

Stored size: 1.78 KB

Contents

require File.dirname(__FILE__)+'/../spec_helper'
require File.dirname(__FILE__)+'/inflector_test_cases'
require 'gorillib/string/inflections'

include InflectorTestCases

describe String do
  describe 'camelize' do
    CamelToUnderscore.each do |cameled, underscored|
      it underscored do
        underscored.camelize.should == cameled
      end
    end

    it 'with lower, downcases the first letter' do
      'Capital'.camelize(:lower).should == 'capital'
    end

    UnderscoreToLowerCamel.each do |underscored, lower_cameled|
      it lower_cameled do
        underscored.camelize(:lower).should == lower_cameled
      end
    end

    CamelWithModuleToUnderscoreWithSlash.each do |cameled, underscored|
      it underscored do
        underscored.camelize.should == cameled
      end
    end
  end

  describe '#snakeize' do
    UnderscoreToLowerCamel.each do |underscored, snaked|
      it underscored do
        underscored.snakeize.should == snaked
      end
    end
  end

  describe '#underscore' do
    CamelToUnderscore.each do |cameled, underscored|
      it cameled do
        cameled.underscore.should == underscored
      end
    end

    CamelToUnderscoreWithoutReverse.each do |cameled, underscored|
      it underscored do
        cameled.underscore.should == underscored
      end
    end

    CamelWithModuleToUnderscoreWithSlash.each do |cameled, underscored|
      it underscored do
        cameled.underscore.should == underscored
      end
    end

    it "HTMLTidy" do
      "HTMLTidy".underscore.should == "html_tidy"
    end

    it "HTMLTidyGenerator" do
      "HTMLTidyGenerator".underscore.should == "html_tidy_generator"
    end
  end

  describe '#demodulize' do
    it 'strips module part' do
      "MyApplication::Billing::Account".demodulize.should == "Account"
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gorillib-0.1.7 spec/string/inflections_spec.rb
gorillib-0.1.6 spec/string/inflections_spec.rb
gorillib-0.1.5 spec/string/inflections_spec.rb
gorillib-0.1.4 spec/string/inflections_spec.rb
gorillib-0.1.3 spec/string/inflections_spec.rb
gorillib-0.1.2 spec/string/inflections_spec.rb
gorillib-0.1.1 spec/string/inflections_spec.rb
gorillib-0.1.0 spec/string/inflections_spec.rb
gorillib-0.0.8 spec/string/inflections_spec.rb