Sha256: 06b5af7289b30c6baa5498bcfe20fe649958279cc88fc4043e5c9f75f3aa98ac

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 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 == ''
      @api.init_javascript(:body_prepend).should =~ /google-analytics.com\/ga.js/
      @api.init_javascript(:body_prepend).should =~ /abcdef/      
      @api.init_javascript(:body_append).should == ''
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
analytical-1.3.0 spec/analytical/google_spec.rb
analytical-1.2.0 spec/analytical/google_spec.rb
analytical-1.1.1 spec/analytical/google_spec.rb
analytical-1.1.0 spec/analytical/google_spec.rb
analytical-1.0.0 spec/analytical/google_spec.rb
analytical-0.16.0 spec/analytical/google_spec.rb
analytical-0.15.0 spec/analytical/google_spec.rb
analytical-0.14.0 spec/analytical/google_spec.rb
analytical-0.13.0 spec/analytical/google_spec.rb
analytical-0.12.0 spec/analytical/google_spec.rb
analytical-0.11.0 spec/analytical/google_spec.rb
analytical-0.10.0 spec/analytical/google_spec.rb
analytical-0.9.0 spec/analytical/google_spec.rb
analytical-0.8.0 spec/analytical/google_spec.rb
analytical-0.7.0 spec/analytical/google_spec.rb
analytical-0.6.0 spec/analytical/google_spec.rb
analytical-0.5.0 spec/analytical/google_spec.rb