Permalink
Browse files

Specs for session examples

  • Loading branch information...
1 parent 5955a4f commit f3f9fbbc3b68aa74b8798ce3c507708f0f5bcd89 @manveru committed Apr 2, 2009
Showing with 40 additions and 0 deletions.
  1. +2 −0 spec/helper.rb
  2. +19 −0 spec/session/cookie.rb
  3. +19 −0 spec/session/counter.rb
View
@@ -0,0 +1,2 @@
+require 'ramaze'
+require 'ramaze/spec'
@@ -0,0 +1,19 @@
+require 'spec/helper'
+require 'chapter/source/session/cookie'
+
+describe 'Cookie' do
+ behaves_like :mock, :session
+
+ should 'count every visit' do
+ get('/').body.should == "This is your visit number 1"
+ get('/').body.should == "This is your visit number 1"
+ get('/').body.should == "This is your visit number 1"
+ end
+
+ should 'not count visit twice if sessions are enabled' do
+ session do |mock|
+ mock.get('/').body.should == 'This is your visit number 1'
+ mock.get('/').body.should == 'This is your visit number 2'
+ end
+ end
+end
@@ -0,0 +1,19 @@
+require 'spec/helper'
+require 'chapter/source/session/counter'
+
+describe 'Counter' do
+ behaves_like :mock, :session
+
+ should 'count every visit' do
+ get('/').body.should == "You are visitor number 1"
+ get('/').body.should == "You are visitor number 2"
+ get('/').body.should == "You are visitor number 3"
+ end
+
+ should 'not count visit twice if sessions are enabled' do
+ session do |mock|
+ mock.get('/').body.should == 'You are visitor number 4'
+ mock.get('/').body.should == 'You are visitor number 4'
+ end
+ end
+end

0 comments on commit f3f9fbb

Please sign in to comment.