Sha256: e22c0fb86ec1e22ebb6e6f88f4dea1e647690ab93e4920cbd6e5a64e3cddefbe

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Staccato::Tracker do

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

  context "#pageview" do
    let(:pageview) {Staccato::Pageview.new(tracker, {})}

    before(:each) do
      pageview.stubs(:track!)
      Staccato::Pageview.stubs(:new).returns(pageview)

      tracker.pageview(path: '/foobar')
    end

    it "creates a new Pageview" do
      Staccato::Pageview.should have_received(:new).with(tracker, path: '/foobar')
    end

    it "tracks on the Pageview" do
      pageview.should have_received(:track!)
    end
  end

  context "#event" do
    let(:event) {Staccato::Event.new(tracker, {})}

    before(:each) do
      event.stubs(:track!)
      Staccato::Event.stubs(:new).returns(event)

      tracker.event(category: 'video', action: 'play')
    end

    it "creates a new Event" do
      Staccato::Event.should have_received(:new).with(tracker, category: 'video', action: 'play')
    end

    it "tracks on the Event" do
      event.should have_received(:track!)
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
staccato-0.2.1 spec/lib/staccato/tracker_spec.rb
staccato-0.2.0 spec/lib/staccato/tracker_spec.rb
staccato-0.1.1 spec/lib/staccato/tracker_spec.rb
staccato-0.1.0 spec/lib/staccato/tracker_spec.rb
staccato-0.0.4 spec/lib/staccato/tracker_spec.rb
staccato-0.0.3 spec/lib/staccato/tracker_spec.rb
staccato-0.0.2 spec/lib/staccato/tracker_spec.rb
staccato-0.0.1 spec/lib/staccato/tracker_spec.rb