Skip to content

Instantly share code, notes, and snippets.

@jdudek
Created March 15, 2011 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdudek/871049 to your computer and use it in GitHub Desktop.
Save jdudek/871049 to your computer and use it in GitHub Desktop.
Session isolation in Capybara/Steak tests
class SessionsController < ApplicationController
def create
session[:created] = true
render :text => "Session created"
end
def check
if session[:created]
render :text => "Session exists"
else
render :text => "Session does not exist"
end
end
end
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
feature "Sessions" do
scenario "Test creating a session" do
visit "/session/create"
page.body.should =~ /Session created/
visit "/session/check"
page.body.should =~ /Session exists/
end
scenario "Test not creating a session" do
visit "/session/check"
page.body.should =~ /Session does not exist/
# expected: /Session does not exist/
# got: "Session exists" (using =~)
end
# after :each do
# page.reset!
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment