Sha256: 87404ee548e9fb3a42b3cafffef64809a0a4a6fe48a737f730eb48a4ce6f40fb

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')


describe String do

  context "formatting" do

    let(:str) { "AA%<a>s BB%<b>s" }
    let(:curly_str) { "AA%{a}s BB%{b}s" }
    let(:pos_str) { "AA%s BB%s" }

    it "should not fail without expected parameters" do
      str.format({}).must_equal 'AA BB'
    end

    it "should replace positional parameters" do
      pos_str.format(['A', 'B']).must_equal 'AAA BBB'
    end

    it "should replace named parameters" do
      str.format(:a => 'A', :b => 'B').must_equal 'AAA BBB'
    end

    it "should replace named parameters with string keys" do
      str.format('a' => 'A', 'b' => 'B').must_equal 'AAA BBB'
    end

    it "should replace named parameters marked with curly brackets" do
      curly_str.format(:a => 'A', :b => 'B').must_equal 'AAA BBB'
    end

  end


  context "camelize" do

    it "should camelize string with underscores" do
      "one_two_three".camelize.must_equal "OneTwoThree"
    end

    it "should not camelize string with dashes" do
      "one-two-three".camelize.must_equal "One-two-three"
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hammer_cli-0.0.18 test/unit/utils_test.rb
hammer_cli-0.0.16 test/unit/utils_test.rb
hammer_cli-0.0.15 test/unit/utils_test.rb
hammer_cli-0.0.14 test/unit/utils_test.rb