Read more

RSpec 3 no longer chooses a spec's type based on its directory

Arne Hartherz
July 22, 2014Software engineer at makandra GmbH

While RSpec 1 and 2 decided that specs inside spec/model are model specs, and those inside spec/features are feature specs (and so on), RSpec 3 will no longer do that by default.

Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot

This will result in errors such as missing routing helpers, etc.

There are 2 ways to fix this:

  • Explicitly set the type on each spec. For example:

    describe '...', type: 'feature' do
      # ...
    end
    
  • Add this to your spec_helper.rb (inside the RSpec.configure block) to restore the old behavior Show archive.org snapshot :

    config.infer_spec_type_from_file_location!
    
Posted by Arne Hartherz to makandra dev (2014-07-22 09:26)