Sha256: 1d125ffc10f6aecb55b0efd51bc3abedded33a3610505572b56b429842b08465

Contents?: true

Size: 1.6 KB

Versions: 6

Compression:

Stored size: 1.6 KB

Contents

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

class InflectorTest < Test::Unit::TestCase
  include InflectorTestCases

  def test_camelize
    CamelToUnderscore.each do |cameled, underscored|
      assert_equal(cameled, underscored.camelize)
    end
  end

  def test_camelize_with_lower_downcases_the_first_letter
    assert_equal('capital', 'Capital'.camelize(:lower))
  end

  def test_snakeize
    UnderscoreToLowerCamel.each do |underscored, snaked|
      assert_equal(snaked, underscored.snakeize)
    end
  end

  def test_underscore_to_lower_camel
    UnderscoreToLowerCamel.each do |underscored, lower_cameled|
      assert_equal(lower_cameled, underscored.camelize(:lower))
    end
  end

  def test_underscore
    CamelToUnderscore.each do |cameled, underscored|
      assert_equal(underscored, cameled.underscore)
    end
    CamelToUnderscoreWithoutReverse.each do |cameled, underscored|
      assert_equal(underscored, cameled.underscore)
    end
    assert_equal "html_tidy", "HTMLTidy".underscore
    assert_equal "html_tidy_generator", "HTMLTidyGenerator".underscore
  end

  def test_camelize_with_module
    CamelWithModuleToUnderscoreWithSlash.each do |cameled, underscored|
      assert_equal(cameled, underscored.camelize)
    end
  end

  def test_underscore_with_slashes
    CamelWithModuleToUnderscoreWithSlash.each do |cameled, underscored|
      assert_equal(underscored, cameled.underscore)
    end
  end

  def test_demodulize
    assert_equal "Account", "MyApplication::Billing::Account".demodulize
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gorillib-0.0.7 test/string/inflections_test.rb
gorillib-0.0.6 test/string/inflections_test.rb
gorillib-0.0.5 test/string/inflections_test.rb
gorillib-0.0.4 test/string/inflections_test.rb
gorillib-0.0.3 test/string/inflections_test.rb
gorillib-0.0.2 test/string/inflections_test.rb