spec/gon/global_spec.rb in gon-5.1.0 vs spec/gon/global_spec.rb in gon-5.1.1

- old
+ new

@@ -57,12 +57,12 @@ Gon.int = 1 Gon.global.int = 1 expect(@base.include_gon).to eq("<script type=\"text/javascript\">" + "\n//<![CDATA[\n" + "window.gon={};" + - "gon.int=1;" + "gon.global={\"int\":1};" + + "gon.int=1;" + "\n//]]>\n" + "</script>") end it 'outputs correct js with a string' do @@ -75,15 +75,15 @@ "</script>") end it 'outputs correct js with a script string' do Gon.global.str = %q(</script><script>alert('!')</script>) - escaped_str = "\"\\u003c/script\\u003e\\u003cscript\\u003ealert('!')\\u003c/script\\u003e\"" + escaped_str = "\\u003c/script\\u003e\\u003cscript\\u003ealert('!')\\u003c/script\\u003e" expect(@base.include_gon).to eq("<script type=\"text/javascript\">" + "\n//<![CDATA[\n" + "window.gon={};" + - "gon.global={\"str\":#{escaped_str}};" + + "gon.global={\"str\":\"#{escaped_str}\"};" + "\n//]]>\n" + "</script>") end it 'outputs correct js with a unicode line separator' do @@ -92,9 +92,20 @@ "\n//<![CDATA[\n" + "window.gon={};" + "gon.global={\"str\":\"&#x2028;\"};" + "\n//]]>\n" + "</script>") + end + + it 'outputs locally overridden value' do + Gon.str = 'local value' + Gon.global.str = 'global value' + expect(@base.include_gon(global_root: '')).to eq("<script type=\"text/javascript\">" + + "\n//<![CDATA[\n" + + "window.gon={};" + + "gon.str=\"local value\";" + + "\n//]]>\n" + + "</script>") end end it 'returns exception if try to set public method as variable' do