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 online protection

Rails professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
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)