rspec before(:each) hook - conditionally apply -
i have following in rails_helper.rb:
rspec.configure |config| # ... config.before(:each, type: :controller) # end end i want define directories, something applicable (in case files under spec/controllers/api directory).
any chance achieve that?
you can use more specialized name rspec filter:
rspec.configure |config| # ... config.before(:each, :subtype => :controllers_api) # end end and in rspec examples in spec/controllers/api, add metadata:
rspec.describe "something", :subtype => :controllers_api end this something should run on examples having :subtype => :controllers_api metadata. did not use :type because there may other behavior defined it.
Comments
Post a Comment