ruby-on-rails – 升级到Rspec 3后,错误“符号与模块失败的比较”

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 升级到Rspec 3后,错误“符号与模块失败的比较”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我刚从Rspec 2.99升级到Rspec 3,我的某些测试出现以下错误.
  1. Failure/Error: Unable to find matching line from backtrace
  2. ArgumentError:
  3. comparison of Symbol with Module Failed

我有以下控制器测试

  1. require 'spec_helper'
  2.  
  3. describe PeopleController,type: :controller do
  4. subject { response }
  5.  
  6. describe :index do
  7. before { get :index }
  8.  
  9. it { should_not be_success }
  10. it { should have_http_status '401' }
  11. end
  12. end

任何想法可能导致错误

解决方法

在描述之后不能使用符号.你需要更换
  1. describe :index do

  1. describe 'index' do

然而,您可以使用符号作为标签,例如…

  1. describe 'index',:awesome do
  2. ...
  3. end

现在运行测试时,您只能使用某个标签来定位测试.

  1. $rspec --tag awesome

猜你在找的Ruby相关文章