Skip to content

Commit

Permalink
adding spec for session saving
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacques Crocker committed Jun 2, 2011
1 parent 4b0f2d2 commit 7d90988
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions spec/functional/aarrr/session_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

require 'rack'

module AARRR
describe Session do

Expand All @@ -26,17 +28,30 @@ module AARRR

AARRR.users.count.should eq(2)
end
end

describe "tracking" do
before(:each) do
@session = Session.new
end

it "should track a custom event" do
@session.track!(:something)

AARRR.events.count.should eq(1)
end
end

describe "tracking" do
before(:each) do
@session = Session.new
end
describe "saving" do
it "should save the session to cookie" do
@session = Session.new
@session.track!(:some_event)

it "should track a custom event" do
@session.track!(:something)
# save session to response
response = Rack::Response.new "some body", 200, {}
@session.save(response)

AARRR.events.count.should eq(1)
end
response.header["Set-Cookie"].should include("_utmarr=#{@session.id}")
end
end

Expand Down

0 comments on commit 7d90988

Please sign in to comment.