spec/it_spec.rb in it-0.2.4 vs spec/it_spec.rb in it-0.2.5
- old
+ new
@@ -3,13 +3,23 @@
require 'spec_helper'
require 'it'
describe It, '.it' do
it "should translate inside the controller as well" do
- I18n.backend.store_translations(:en, :test1 => "I have a %{link:link to Rails} in the middle.")
- expect(It.it("test1", :link => It.link("http://www.rubyonrails.org"))).to eq('I have a <a href="http://www.rubyonrails.org">link to Rails</a> in the middle.')
+ I18n.backend.store_translations(:en, test1: "I have a %{link:link to Rails} in the middle.")
+ expect(It.it("test1", link: It.link("http://www.rubyonrails.org"))).to eq('I have a <a href="http://www.rubyonrails.org">link to Rails</a> in the middle.')
end
+
+ it 'should use default key if no translation is present on specified key' do
+ I18n.backend.store_translations(:en, fallback: 'this is a fallback')
+ expect(It.it('a.missing.key', default: :fallback)).to eq('this is a fallback')
+ end
+
+ it 'should use default string if key is missing' do
+ expect(It.it('a.missing.key', default: 'this is a fallback string')).to eq('this is a fallback string')
+ end
+
end
describe It, '.link' do
it "should return an It::Link object" do
expect(It.link("https://www.github.com").class).to eq(It::Link)
@@ -18,11 +28,11 @@
it "should accept one param" do
expect { It.link("http://www.rubyonrails.org/") }.not_to raise_error
end
it "should accept two params" do
- expect { It.link("http://www.rubyonrails.org/", {:id => "identity", :class => "classy"}) }.not_to raise_error
+ expect { It.link("http://www.rubyonrails.org/", {id: "identity", class: "classy"}) }.not_to raise_error
end
it "should raise ArgumentError, if called with three params" do
expect { It.link("http://www.rubyonrails.org/", {}, :blubb) }.to raise_error(ArgumentError)
end
@@ -36,10 +46,10 @@
it "should work with a param" do
expect { It.tag(:b) }.not_to raise_error
end
it "should accept two params" do
- expect { It.tag(:b, :class => "very_bold") }.not_to raise_error
+ expect { It.tag(:b, class: "very_bold") }.not_to raise_error
end
it "should raise an ArgumentError if called with three params" do
expect { It.tag(:b, {}, :blubb) }.to raise_error(ArgumentError)
end