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

冷暖自知 提交于 2019-12-08 16:25:13

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/24043426/error-comparison-of-symbol-with-module-failed-after-upgrading-to-rspec-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!