spec/ruby/i18n/js/segment_spec.rb in i18n-js-3.8.3 vs spec/ruby/i18n/js/segment_spec.rb in i18n-js-3.8.4

- old
+ new

@@ -255,7 +255,32 @@ MyNamespace.translations || (MyNamespace.translations = {}); MyNamespace.translations["en"] = I18n.extend((MyNamespace.translations["en"] || {}), JSON.parse('{"b":"Test","a":"Test"}')); EOF end end + + context "when translation entries contain procs" do + let(:translations) do + { + en: { + "test" => "Test", + "i18n" => {"plural" => {"rule" => proc {} }}, + }, + fr: { + "test" => "Test2", + "i18n" => {"plural" => {"rule" => proc {} }}, + }, + } + end + + it "should write files without procs or their string representations" do + file_should_exist "segment.js" + + expect(File.open(File.join(temp_path, "segment.js")){|f| f.read}).to eql <<-EOF +MyNamespace.translations || (MyNamespace.translations = {}); +MyNamespace.translations["en"] = I18n.extend((MyNamespace.translations["en"] || {}), JSON.parse('{"i18n":{"plural":{}},"test":"Test"}')); +MyNamespace.translations["fr"] = I18n.extend((MyNamespace.translations["fr"] || {}), JSON.parse('{"i18n":{"plural":{}},"test":"Test2"}')); + EOF + end + end end end