Sha256: 10f3c63f6ce369ba7dc14bec2a0e2f0cd71f406c571e61b8f3a4596f87d816ac
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
$:.unshift(File.dirname(__FILE__)) require 'spec_helper' describe "google_analytics plugin" do def setup_google_analytics_plugin(profile_id, mode) fake_plugin(:google_analytics) { |plugin| plugin.mode = mode plugin.conf['google_analytics.profile'] = profile_id } end describe "should render javascript" do before do @plugin = setup_google_analytics_plugin('53836-1', 'latest') end it "for footer" do snippet = @plugin.footer_proc snippet.should == expected_html_footer_snippet end end describe "should render javascript" do before do @plugin = setup_google_analytics_plugin('53836-1', 'conf') end it "for footer" do snippet = @plugin.footer_proc snippet.should be_empty end end describe "should not render when profile_id is empty" do before do @plugin = setup_google_analytics_plugin(nil, 'latest') end it "for footer" do snippet = @plugin.footer_proc snippet.should be_empty end end def expected_html_footer_snippet expected = <<-SCRIPT <script type="text/javascript"><!-- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape('%3Cscript src="' + gaJsHost + 'google-analytics.com/ga.js" type="text/javascript"%3E%3C/script%3E')); // --></script> <script type="text/javascript"><!-- try { var pageTracker = _gat._getTracker("UA-53836-1"); pageTracker._trackPageview(); } catch (err) {} // --></script> SCRIPT expected.gsub( /^\t/, '' ).chomp end end
Version data entries
4 entries across 4 versions & 1 rubygems