Sha256: cbd2bfa91731a90b41ffa3fb99969b97fe2ce99b52b51c8a1fd17835a73cc471

Contents?: true

Size: 879 Bytes

Versions: 5

Compression:

Stored size: 879 Bytes

Contents

require "spec_helper"

describe String do

  describe "#snake_case" do
    it "lowercases one word CamelCase" do
      "Merb".snake_case.should == "merb"
    end

    it "makes one underscore snake_case two word CamelCase" do
      "MerbCore".snake_case.should == "merb_core"
    end

    it "handles CamelCase with more than 2 words" do
      "SoYouWantContributeToMerbCore".snake_case.should == "so_you_want_contribute_to_merb_core"
    end

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

    it "does NOT change one word lowercase" do
      "merb".snake_case.should == "merb"
    end

    it "leaves snake_case as is" do
      "merb_core".snake_case.should == "merb_core"
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nori-0.2.4 spec/nori/core_ext/string_spec.rb
nori-0.2.3 spec/nori/core_ext/string_spec.rb
nori-0.2.2 spec/nori/core_ext/string_spec.rb
nori-0.2.1 spec/nori/core_ext/string_spec.rb
nori-0.2.0 spec/nori/core_ext/string_spec.rb