blob: e8d0467571b3a62cbdb2b8acd32a8d3981afdddb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "when using i18n" do
it "should not complain if we're missing variables from the string" do
result = _('Hello', :dip => 'hummus')
result.should == 'Hello'
result = _('Hello {{dip}}', :dip => 'hummus')
result.should == 'Hello hummus'
end
it "should assume that simple translations are always html safe" do
_("Hello").should be_html_safe
end
end
describe "gettext_interpolate" do
context "html unsafe string" do
let(:string) { "Hello {{a}}" }
it "should give an unsafe result" do
result = gettext_interpolate(string, :a => "foo")
result.should == "Hello foo"
result.should_not be_html_safe
end
it "should give an unsafe result" do
result = gettext_interpolate(string, :a => "foo".html_safe)
result.should == "Hello foo"
result.should_not be_html_safe
end
end
context "html safe string" do
let(:string) { "Hello {{a}}".html_safe }
it "should quote the input if it's unsafe" do
result = gettext_interpolate(string, :a => "foo&")
result.should == "Hello foo&"
result.should be_html_safe
end
it "should not quote the input if it's safe" do
result = gettext_interpolate(string, :a => "foo&".html_safe)
result.should == "Hello foo&"
result.should be_html_safe
end
end
end
|