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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -