require 'spec_helper' describe Split::Analytics do include Split::Helper it 'should generate valid analytics javascript' do tracking_code = tracking_code(account: 'UA-12345-6') expect(tracking_code).to eql(%Q{ \n}) end it 'should generate valid analytics javascript with arbitrary tracker object methods' do tracker_methods = { setDomainName: 'example.com', # String argument setAllowLinker: true, # Boolean argument clearOrganic: '' # No argument } tracking_code = tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods) expect(tracking_code).to eql(%Q{ \n}) end it 'should add custom variables for every test the user is involved in' do first_alt = ab_test('link_colour', 'red', 'blue') expect(ab_user.active_experiments).to eql({'link_colour' => first_alt}) tracking_code = tracking_code(account: 'UA-12345-6') expect(tracking_code).to eql(%Q{ \n}) end it 'uses doubleclick as tracker url' do tracking_code = tracking_code(account: "UA-12345-6", tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js') expect(tracking_code).to eql(%Q{ \n}) end end