Read more

RSpec: Change the type of a spec regardless of the folder it lives in

Henning Koch
October 17, 2012Software engineer at makandra GmbH

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.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

If you want that magic context for a spec in another folder, use the :type option:

describe CakesController, :type => :controller do
  ...
end
Posted by Henning Koch to makandra dev (2012-10-17 14:54)