Q:

How to perform tests based on the type of test in RSpec

Given the following test file
require 'rails_helper'

RSpec.describe PurchaseCarService, type: :service do
  #...
end

How can I perform common tests for all specs of type :service?
I intend to have all (e.g.) Service objects enforce common Service standards.
Regards,

A:

Using filtering I was able to run additional tests before each describes block with the context type: :service.
For example
RSpec.configure do |c|
  c.before(:example, type: :service) do
    # Run some common tests
  end
end

