Sha256: de4e372943425a06615c599b5f3f206a366927a618235d770aef4bf6782483ef

Contents?: true

Size: 993 Bytes

Versions: 79

Compression:

Stored size: 993 Bytes

Contents

require 'test_helper'

describe Crack::Util do
  describe "snake_case" do
    it "lowercases one word CamelCase" do
      Crack::Util.snake_case("Merb").must_equal "merb"
    end

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

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

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

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

    it "leaves snake_case as is" do
      Crack::Util.snake_case("merb_core").must_equal "merb_core"
    end
  end
end

Version data entries

79 entries across 71 versions & 13 rubygems

Version Path
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/crack-0.4.3/test/string_test.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/crack-0.4.3/test/string_test.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/crack-0.4.3/test/string_test.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/crack-0.4.3/test/string_test.rb
crack-without-safe_yaml-0.4.3 test/string_test.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/crack-0.4.2/test/string_test.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/crack-0.4.2/test/string_test.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/crack-0.4.2/test/string_test.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/crack-0.4.3/test/string_test.rb
dwolla_swagger-1.0.6 vendor/bundle/ruby/2.2.0/gems/crack-0.4.3/test/string_test.rb
crack-0.4.3 test/string_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/crack-0.4.2/test/string_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/crack-0.4.2/test/string_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/crack-0.4.2/test/string_test.rb
whos_dated_who-0.1.0 vendor/bundle/gems/crack-0.4.2/test/string_test.rb
whos_dated_who-0.0.1 vendor/bundle/gems/crack-0.4.2/test/string_test.rb
crack-0.4.2 test/string_test.rb
crack-0.4.1 test/string_test.rb
crack-0.4.0 test/string_test.rb