Spree List --
[Note I have asked same question to Capybara list]
We're having some problem with a suite of integration tests when upgrading from Spree 2.2 to Spree 2.3
We used to use page.set_rack_session but due to some changes in Spree code (2.3 upgrade), this no longer works because we now need to create a signed cookie to set the current order on the session.
Unfortunately I need direct access to the Spree code into order to create the signed cookie, which I do not have because Capybara is operating in a different session environment as the Rails app it is hitting.
Unfortunately, nearly all of my integration tests won't work any more because I was relying on being able to do this in my set up:
before(:each) do
page.set_rack_session(:order_id =>
order.id)
page.set_rack_session(:access_token => order.guest_token)
end
I realize that the "right" way to do this would be to create Capy setup that logs the user in via the real Log In interface, adds an item their cart, etc.
However, in my Spree object chain I have objects that have levels and levels of nested related data -- all relying on a (large, well-written and maintained) catalog of Factories. That's why -- in my pre-Spree 2.3 tests -- I was setting the rack session information. The idea here was that what you see in the "before" filters are setup logic -- not the subject of the tests themselves -- and so in a way it can be thought of similar to mocking (without an actual mock). Essentially, what I'm saying here is that how the order_id or access_token get set on the session doesn't actually matter, it's a precursor to the expectations I will assert during the test.
Basically it would be prohibitively inefficient as the developer to not be able to use my Factories in my Capybara tests as "setup" expectations, and since Spree 2.3 needs a signed cookie, I can't see anyway to set up the signed cookie for the user without access to the Spree rails code.
Are there any good work-arounds for this problem or insight into best practices here?
Thanks,
Jason
----
Jason Fleetwood-Boldt