0

I'm migrating from postman to rspec/rswag for API documentation and testing.

I can get a simple example working that requires no auth, but for endpoints that require a login I'm unsure how to proceed.

In postman, I would create a test which extracted the values from the response json and set the global/collection variable to that value

How would I do the same in rspec? The README doesn't have any examples of this pattern.

atg
  • 127
  • 2
  • 13
  • this would be an anti-pattern in RSpec. RSpec tests are meant to run in isolation and be order-agnostic. If you want to perform a login prior to a set of tests, you can probably do so with a before hook https://relishapp.com/rspec/rspec-core/v/3-10/docs/hooks/before-and-after-hooks – TonyArra Apr 06 '22 at 01:22
  • 1
    thanks! i suspected as much. I think im going to stick to supertest and postman for API testing – atg Apr 07 '22 at 22:43

0 Answers0