# Functional test - changing a session variable?

**URL:** <https://www.ruby-forum.com/t/functional-test-changing-a-session-variable/105099>\
**Category:** Rails\
**Created:** [May 25, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/functional-test-changing-a-session-variable/105099 "2007-05-25T19:24:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [May 25, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/functional-test-changing-a-session-variable/105099/1 "2007-05-25T19:24:37Z")

</div>

i defined in the setup some session variables

def setup  
@controller = RecommandationsController.new  
@request = ActionController::TestRequest.new  
@response = ActionController::TestResponse.new  
@request.session[:user] = users(:arthur) #2  
@request.session[:city] = villes(:auray)  
@request.session[:infos\_list] =  
Ouroboros.from\_a(villes(:auray).infos)  
end

I would like to change some of these session variables in the same test  
before the posts, is it possible ?  
ot should I actually write 3 tests ?

test\_create  
post :create, :id =\> ‘100’, :comment =\> “ok…”, :notation =\> ‘3’  
…  
@request.session[:user] = users(:caroline) #16  
post :create, :id =\> ‘100’, :comment =\> “ok…”, :notation =\> ‘3’  
…  
@request.session[:user] = users(:clementine) #5  
post :create, :id =\> ‘100’, :comment =\> “ok…”, :notation =\> ‘3’

thanks for your comments
