Sha256: 2f9126b631c9b50f37fccb28f895c6237ec5122ae865dc3136b6cc62c0847c88

Contents?: true

Size: 1022 Bytes

Versions: 5

Compression:

Stored size: 1022 Bytes

Contents

require 'test_helper'

class CrackTest < Test::Unit::TestCase
  context "snake_case" do
    should "lowercases one word CamelCase" do
      Crack::Util.snake_case("Merb").should == "merb"
    end

    should "makes one underscore snake_case two word CamelCase" do
      Crack::Util.snake_case("MerbCore").should == "merb_core"
    end

    should "handles CamelCase with more than 2 words" do
      Crack::Util.snake_case("SoYouWantContributeToMerbCore").should == "so_you_want_contribute_to_merb_core"
    end

    should "handles CamelCase with more than 2 capital letter in a row" do
      Crack::Util.snake_case("CNN").should == "cnn"
      Crack::Util.snake_case("CNNNews").should == "cnn_news"
      Crack::Util.snake_case("HeadlineCNNNews").should == "headline_cnn_news"
    end

    should "does NOT change one word lowercase" do
      Crack::Util.snake_case("merb").should == "merb"
    end

    should "leaves snake_case as is" do
      Crack::Util.snake_case("merb_core").should == "merb_core"
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
simple-client-0.0.3 vendor/bundle/ruby/1.9.1/gems/crack-0.3.1/test/string_test.rb
crack-0.3.2 test/string_test.rb
simple-client-0.0.2 vendor/bundle/ruby/1.8/gems/crack-0.3.1/test/string_test.rb
crack-0.3.1 test/string_test.rb
crack-0.3.0 test/string_test.rb