spec/session_spec.rb in fnordmetric-0.7.1 vs spec/session_spec.rb in fnordmetric-0.7.3
- old
+ new
@@ -23,31 +23,31 @@
@redis.del("#{@namespace}-session-#{@md5_key}-events")
@redis.del("#{@namespace}-session-#{@md5_key}-data")
end
it "should add a new session on intialize" do
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@redis.zcard(@sessions).should == 1
end
it "should add a new session on intialize and hash the session token" do
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@redis.zrange(@sessions, 0, -1).should == [ @md5_key]
end
it "should add a new session on intialize and set the timestamp as score" do
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@@ -55,21 +55,21 @@
end
it "should update the timestamp on a existing session" do
@redis.zadd(@sessions, @now-10, @md5_key)
@redis.zscore(@sessions, @md5_key).to_i.should == @now-10
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@redis.zscore(@sessions, @md5_key).to_i.should == @now
end
it "should add the event_id to the session-event set on a new session" do
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@@ -80,11 +80,11 @@
it "should store a name in the session data" do
event_data = @event.merge(
:_type => "_set_name",
:name => "Horst Mayer"
)
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => event_data,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@@ -95,11 +95,11 @@
it "should store a picture in the session data" do
event_data = @event.merge(
:_type => "_set_picture",
:url => "http://myhost/mypic.jpg"
)
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => event_data,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@@ -111,11 +111,11 @@
event_data = @event.merge(
:_type => "_set_data",
:fnord => "blubb",
:foobar => "123"
)
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => event_data,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@@ -128,11 +128,11 @@
event_data = @event.merge(
:_type => "_set_data",
:fnord => "blubb",
:foobar => "123"
)
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => event_data,
:session_data_ttl => 10,
:redis => @redis_wrap
)
@@ -157,61 +157,61 @@
end
it "should find all sessions" do
create_session("sess533", @now, {})
create_session("sess343", @now, {})
- Session.all(@opts).length.should == 2
+ FnordMetric::Session.all(@opts).length.should == 2
end
it "should find all sessions and return session objects" do
create_session("sess523", @now, {})
- Session.all(@opts).first.should be_a(FnordMetric::Session)
+ FnordMetric::Session.all(@opts).first.should be_a(FnordMetric::Session)
end
it "should find a session and return a session object" do
create_session("sess223", @now, {})
- sess = Session.find(Digest::MD5.hexdigest("sess223"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess223"), @opts)
sess.should be_a(FnordMetric::Session)
sess.session_key.should == Digest::MD5.hexdigest("sess223")
end
it "should find a sessions and return a session object with data" do
create_session("sess123", @now, { :fnord => "blubb" })
- sess = Session.find(Digest::MD5.hexdigest("sess123"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess123"), @opts)
sess.fetch_data!
sess.data(:fnord).should == "blubb"
end
it "should not include special attributes in data" do
event_data = { :_name => "Horst Mayer", :_picture => "http://myhost/mypic.jpg" }
create_session("sess173", @now, event_data)
- sess = Session.find(Digest::MD5.hexdigest("sess173"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess173"), @opts)
sess.fetch_data!
sess.data(:_name).should == nil
sess.data(:_picture).should == nil
end
it "should find a session and return a session object with picture" do
event_data = { :_name => "Horst Mayer", :_picture => "http://myhost/mypic.jpg" }
create_session("sess163", @now, event_data)
- sess = Session.find(Digest::MD5.hexdigest("sess163"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess163"), @opts)
sess.fetch_data!
sess.picture.should == "http://myhost/mypic.jpg"
end
it "should find a session and return a session object with name" do
event_data = { :_name => "Horst Mayer", :_picture => "http://myhost/mypic.jpg" }
create_session("sess143", @now, event_data)
- sess = Session.find(Digest::MD5.hexdigest("sess143"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess143"), @opts)
sess.fetch_data!
sess.name.should == "Horst Mayer"
end
it "should find a session and return a session object with event_ids" do
sesshash = create_session("sess923", @now, {})
@redis_wrap.zadd("#{@namespace}-session-#{sesshash}-events", @now, "shmoo")
@redis_wrap.zadd("#{@namespace}-session-#{sesshash}-events", @now, "fnord")
- sess = Session.find(sesshash, @opts)
+ sess = FnordMetric::Session.find(sesshash, @opts)
sess.fetch_event_ids!
sess.event_ids.should include("shmoo")
sess.event_ids.should include("fnord")
end