rspec before(:each) hook - conditionally apply
问题 I have following in my rails_helper.rb : RSpec.configure do |config| # ... config.before(:each, type: :controller) do # SOMETHING end end I want to define directories, to which this SOMETHING will be applicable (in my case ONLY to files under spec/controllers/api directory). Any chance to achieve that? 回答1: You can use a more specialized name for your RSpec filter: RSpec.configure do |config| # ... config.before(:each, :subtype => :controllers_api) do # SOMETHING end end And then in your