Sha256: 33cc7db8bc33d49bbd79ebc3e6df4a497c364b809f7ded57715566f0c1a8d445

Contents?: true

Size: 900 Bytes

Versions: 21

Compression:

Stored size: 900 Bytes

Contents

require File.expand_path("../spec_helper", File.dirname(__FILE__))
require 'gettext_i18n_rails/string_interpolate_fix'

describe "String#%" do
  it "is not safe if it was not safe" do
    result = ("<br/>%{x}" % {:x => 'a'})
    result.should == '<br/>a'
    result.html_safe?.should == false
  end

  it "stays safe if it was safe" do
    result = ("<br/>%{x}".html_safe % {:x => 'a'})
    result.should == '<br/>a'
    result.html_safe?.should == true
  end

  it "escapes unsafe added to safe" do
    result = ("<br/>%{x}".html_safe % {:x => '<br/>'})
    result.should == '<br/>&lt;br/&gt;'
    result.html_safe?.should == true
  end

  it "does not escape unsafe if it was unsafe" do
    result = ("<br/>%{x}" % {:x => '<br/>'})
    result.should == '<br/><br/>'
    result.html_safe?.should == false
  end

  it "does not break array replacement" do
    "%ssd" % ['a'].should == "asd"
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
zena-1.2.8 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.2.7 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.2.6 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.2.5 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.2.4 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.2.3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.2.2 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.2.1 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.2.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.1.3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.1.2 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.1.1 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.1.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.0.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
gettext_i18n_rails-0.2.20 spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
zena-1.0.0.rc3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
gettext_i18n_rails-0.2.19 spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
gettext_i18n_rails-0.2.18 spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
gettext_i18n_rails-0.2.17 spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
gettext_i18n_rails-0.2.16 spec/gettext_i18n_rails/string_interpolate_fix_spec.rb