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

Posted Almost 10 years ago. Visible to the public.

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.

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!
    
Arne Hartherz
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2014-07-22 07:26)