The rack does not support on-demand session transfer anymore (Rack> = v1.0). Read this post for more information on this.
- , . , , :
post '/set_sess_var/:id'
session[:user_id] = params[:id]
end
, , , :
get '/get_user_attributes'
User.find(session[:user_id]).attributes
end
, , , . rspec, , :
it "should print out user attributes" do
user_id = 1
post '/set_sess_var/' + user_id
get '/get_user_attributes'
last_response.body.should == User.find(user_id).attributes
end
, ( Rspec, spec_helper.rb controller_spec.rb):
def set_session_var(user_id)
post '/set_sess_var/' + user_id
end
, :
it "should print out user attributes" do
set_session_var(1)
get '/get_user_attributes'
last_response.body.should == User.find(1).attributes
end