Sha256: 1076c72398ea457ca9bf3a9977d8e819f54b19fee3b04605a93bd7de396d85f8

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

current_folder = File.dirname(__FILE__)
require File.join(current_folder,'..','spec_helper')

#just to make sure we did not mess up while copying...
describe String do
  it "substitudes using % + Hash" do
    "x%{name}y" %{:name=>'a'}.should == 'xay'
  end

  describe 'old sprintf style' do
    it "substitudes using % + Array" do
      ("x%sy%s" % ['a','b']).should == 'xayb'
    end

    it "does not remove %{} style replacements" do
      ("%{name} x%sy%s" % ['a','b']).should == '%{name} xayb'
    end

    it "does not remove %<> style replacement" do
       ("%{name} %<num>f %s" % ['x']).should == "%{name} %<num>f x"
    end
  end

  describe 'ruby 1.9 style %< replacement' do
    it "subsitutes %<something>d" do
      ("x%<hello>dy" % {:hello=>1}).should == 'x1y'
    end

    it "substitutes #b" do
      ("%<num>#b" % {:num => 1}).should == "0b1"
    end


  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grosser-fast_gettext-0.4.2 spec/vendor/string_spec.rb
grosser-fast_gettext-0.4.3 spec/vendor/string_spec.rb
grosser-fast_gettext-0.4.4 spec/vendor/string_spec.rb
grosser-fast_gettext-0.4.5 spec/vendor/string_spec.rb
grosser-fast_gettext-0.4.7 spec/vendor/string_spec.rb