Read more

RSpec: Inferring spec type from file location

Emanuel
December 21, 2021Software engineer at makandra GmbH

RSpec Rails can automatically mix in different behaviors to your tests based on their type tag, for example enabling you to call get and
post in specs with the tag type: :request.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Alternatively you can skip these tags by setting the config config.infer_spec_type_from_file_location! in the spec_helper.rb. This will automatically choose the right type context based on the file location Show archive.org snapshot of the test.

For instance, specs in spec/features/requests are automatically tagged with { type: :request }.

Posted by Emanuel to makandra dev (2021-12-21 13:44)