RSpec: Change the type of a spec regardless of the folder it lives in
In a Rails application, *_spec.rb
files get special treatment depending on the file's directory. E.g. when you put a spec in spec/controllers
your examples will have some magic context like controller
, post
or get
that appears out of nowhere.
If you want that magic context for a spec in another folder, use the :type
option:
describe CakesController, :type => :controller do
...
end