I18n.backend.store_translations(:en, :test1 => "I'm containing a %{link:link to Rails} in the middle.")
I18n.backend.store_translations(:de, :test1 => "Ich enthalte einen %{link:Link zu Rails} in der Mitte.")
-
+
@view=ActionView::Base.new
@controller=ActionController::Base.new
@view.controller =@controller
end
-
+
after do
I18n.locale =:en
end
-
+
it "should insert the link into the string"do
@view.it("test1", :link => It.link("http://www.rubyonrails.org")).should =='I\'m containing a <a href="http://www.rubyonrails.org">link to Rails</a> in the middle.'
end
-
+
it "should insert the link into the German translation"do
I18n.locale =:de
@view.it("test1", :link => It.link("http://www.rubyonrails.org")).should =='Ich enthalte einen <a href="http://www.rubyonrails.org">Link zu Rails</a> in der Mitte.'
end
-
+
it "should allow link options to be set"do
@view.it("test1", :link => It.link("http://www.rubyonrails.org", :target => "_blank")).should =='I\'m containing a <a href="http://www.rubyonrails.org" target="_blank">link to Rails</a> in the middle.'
end
-
+
it "should support the plain thing"do
@view.it("test1", :link => It.plain("%s[http://www.rubyonrails.org]")).should =='I\'m containing a link to Rails[http://www.rubyonrails.org] in the middle.'
end
-
+
it "should parse other tags as well"do
@view.it("test1", :link => It.tag(:b, :class => "classy")).should =='I\'m containing a <b class="classy">link to Rails</b> in the middle.'
@view.it("test2", :link => It.link("http://www.rubyonrails.org")).should =='<a href="hax0r"> & <a href="http://www.rubyonrails.org">link -> Rails</a> in <b>the middle</b>.'
end
-
+
it "should also work with 2 links"do
I18n.backend.store_translations(:en, :test3 => "I like %{link1:rails} and %{link2:github}.")
@view.it("test3", :link1 => It.link("http://www.rubyonrails.org"), :link2 => It.link("http://www.github.com")).should =='I like <a href="http://www.rubyonrails.org">rails</a> and <a href="http://www.github.com">github</a>.'
end
-
+
it "should allow normal I18n interpolations"do
I18n.backend.store_translations(:en, :test4 => "I'm containing a %{link:link to Rails} in the %{position}.")
@view.it("test4", :link => It.link("http://www.rubyonrails.org"), :position => "middle").should =='I\'m containing a <a href="http://www.rubyonrails.org">link to Rails</a> in the middle.'
end
-
+
it "should allow Intergers as normal interpolation"do
+ @view.it('test1', :locale => "de", :link => It.link("http://www.rubyonrails.org")).should =='Ich enthalte einen <a href="http://www.rubyonrails.org">Link zu Rails</a> in der Mitte.'
0 comments on commit
de899a2