Sha256: 394ccf48269067c7de8b16a1be73afe03f08758cb64cbdfa14358e8d30260fc0

Contents?: true

Size: 909 Bytes

Versions: 52

Compression:

Stored size: 909 Bytes

Contents

require "spec_helper"

describe String do

  describe "#snakecase" do
    it "lowercases one word CamelCase" do
      expect("Merb".snakecase).to eq("merb")
    end

    it "makes one underscore snakecase two word CamelCase" do
      expect("MerbCore".snakecase).to eq("merb_core")
    end

    it "handles CamelCase with more than 2 words" do
      expect("SoYouWantContributeToMerbCore".snakecase).to eq("so_you_want_contribute_to_merb_core")
    end

    it "handles CamelCase with more than 2 capital letter in a row" do
      expect("CNN".snakecase).to eq("cnn")
      expect("CNNNews".snakecase).to eq("cnn_news")
      expect("HeadlineCNNNews".snakecase).to eq("headline_cnn_news")
    end

    it "does NOT change one word lowercase" do
      expect("merb".snakecase).to eq("merb")
    end

    it "leaves snake_case as is" do
      expect("merb_core".snakecase).to eq("merb_core")
    end
  end

end

Version data entries

52 entries across 44 versions & 6 rubygems

Version Path
nori-2.7.0 spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/nori-2.6.0/spec/nori/core_ext/string_spec.rb