Sha256: b491459fda5d36d8a07ca71bf9b3ca14a7113c81cf49c518e0983f261b540b6b

Contents?: true

Size: 958 Bytes

Versions: 8

Compression:

Stored size: 958 Bytes

Contents

require 'spec_helper'

describe Staccato do

  context 'configuring a tracker' do

    let(:tracker) {Staccato.tracker 'UA-XXXX-Y'}

    it 'has an assigned id' do
      expect(tracker.id).to eq('UA-XXXX-Y')
    end

    it 'uses a uuid for the client_id' do
      SecureRandom.stubs(:uuid).returns("a-uuid")

      expect(tracker.client_id).to eq('a-uuid')
    end

    context 'given a hit' do
      let(:tracker) {Staccato.tracker('UA-XXXX-Y')}

      let(:event) {
        tracker.build_event({
          category: 'email',
          action: 'open',
          label: 'welcome',
          value: 1
        })
      }

      before(:each) do
        SecureRandom.stubs(:uuid).returns("a-uuid")
      end

      it 'turns a hit into a URL string' do
        url = "http://www.google-analytics.com/collect?v=1&tid=UA-XXXX-Y&cid=a-uuid&t=event&ec=email&ea=open&el=welcome&ev=1"

        expect(Staccato.as_url(event)).to eq(url)
      end
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
staccato-0.5.3 spec/lib/stacatto_spec.rb
staccato-0.5.2 spec/lib/stacatto_spec.rb
staccato-0.5.1 spec/lib/stacatto_spec.rb
staccato-0.5.0 spec/lib/stacatto_spec.rb
staccato-0.4.7 spec/lib/stacatto_spec.rb
staccato-0.4.6 spec/lib/stacatto_spec.rb
staccato-0.4.5 spec/lib/stacatto_spec.rb
staccato-0.4.4 spec/lib/stacatto_spec.rb