Sha256: bed3bb98c670f8b77e0dc15adde0b9b18a48a759960a04c79a928678015184ec

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Analytical::Google::Api" do
  before(:each) do
    @parent = mock('api', :options=>{:google=>{:key=>'abc'}})
  end
  describe 'on initialize' do
    it 'should set the command_location' do
      a = Analytical::Google::Api.new @parent, {:key=>'abc'}
      a.tracking_command_location.should == :body_prepend
    end
    it 'should set the options' do
      a = Analytical::Google::Api.new @parent, {:key=>'abc'}
      a.options.should == {:key=>'abc'}
    end
  end
  describe '#track' do
    it 'should return the tracking javascript' do
      @api = Analytical::Google::Api.new @parent, {:key=>'abcdef'}
      @api.track('pagename', {:some=>'data'}).should == "googleAnalyticsTracker._trackPageview(\"pagename\");"
    end
  end
  describe '#identify' do
    it 'should return an empty string' do
      @api = Analytical::Google::Api.new @parent, {:key=>'abcdef'}
      @api.identify('nothing', {:matters=>'at all'}).should == ''
    end
  end
  describe '#init_javascript' do
    it 'should return the init javascript' do
      @api = Analytical::Google::Api.new @parent, {:key=>'abcdef'}
      @api.init_javascript[:head].should be_nil
      @api.init_javascript[:body_prepend].should =~ /google-analytics.com\/ga.js/
      @api.init_javascript[:body_prepend].should =~ /abcdef/      
      @api.init_javascript[:body_append].should be_nil            
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
analytical-0.3.0 spec/analytical/google_spec.rb