RSpec: Inferring spec type from file location

Updated . Posted . Visible to the public. Repeats.

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.

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 }.

Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2021-12-21 12:44)