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 online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
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)