railsware / rack_session_access

Rack middleware that provides access to rack.session environment
MIT License
257 stars 29 forks source link

`get_rack_session` and `get_rack_session_key` reset Capybara page.current_url #10

Closed thewatts closed 10 years ago

thewatts commented 10 years ago

Trying to pull data via the url (parameter information), and then work the with data to find objects in the database.

However, when I call page.get_rack_session_key(current_order_key), the value for page.current_url changes from http://www.example.com/:restaurant_slug to http://www.example.com/rack_session.raw = preventing me from then working with the URL.

Am I doing something wrong?

Thanks!

ayanko commented 10 years ago

Yes. We don't directly access app session (it's not even possible for JS cabybara drivers selenium, webkit, ...). Getting/Setting rack session is done via GET/PUT request to middleware app injected in to your application. So that page.current_url changes. Nothing wrong here.

scenario 'Visit page after ordering' do
  shop_id = page.get_rack_session_key(:current_shop_id)
  # current_url is http://www.example.com/rack_session.raw
  visit shop_path(shop_id)
  # current_url is http://www.example.com/shops/:id
  next_shop_id = page.get_rack_session_key(:next_shop_id)
  # current_url is http://www.example.com/rack_session.raw
  ...
end
thewatts commented 10 years ago

Cool! Thanks :)

And thanks for this excellent gem!