Search code examples
ruby-on-railsrspecrspec-rails

Error `comparison of Symbol with Module failed` after upgrading to Rspec 3


I just upgraded from Rspec 2.99 to Rspec 3 and am getting the following error for some of my tests.

Failure/Error: Unable to find matching line from backtrace
ArgumentError:
  comparison of Symbol with Module failed

I have the following controller test

require 'spec_helper'

describe PeopleController, type: :controller do
  subject { response }

  describe :index do
    before { get :index }

    it { should_not be_success }
    it { should have_http_status '401' }
  end
end

Any idea what might be causing the error?


Solution

  • You can't use symbols after describe anymore. You need to replace

    describe :index do
    

    with

    describe 'index' do
    

    You are however able to use symbols as tags, for example...

    describe 'index', :awesome do
      ...
    end
    

    Now when running the tests you can target only tests with a certain tag.

    $ rspec --tag awesome