piątek, 6 lipca 2012

Rspec helper for sign in

After I've changed sign in logic, to use only facebook authorization my helper to sign in user in tests crashes. I used omniauth-facebook gem to handle authorization and clearance as legacy gem.
I've tried many times handle that problem.

  1. Easiest way is click and fill, but that means you need connect to fb in test. We can handle that with VCR, which will mock your fb requests. Unlucky  on every test we have different user id, so recorded request will no match.
  2.  Mock everything !!! Yeah, I thought I'll mock essential methods in application controller, current_user, signed_in? etc. In rspec we use rspec-mock, which has similar api as mocha This was little ugly, but it doesn't works. Rspec-mock has some bug with mocking methods in base class using any_instance.
  3. The final solution was already designed in gem omiauth: 



Brak komentarzy:

Prześlij komentarz