加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rspec,shoulda和spork不能一起工作

发布时间:2020-12-16 20:33:28 所属栏目:百科 来源:网络整理
导读:当我运行rspec spec / models结果就OK了. 但是当我使用spork时,每个测试应该是一个宏(像它应该是validate_presence_of(:title)}),使用失败的错误,如:undefined method’validate_presence_of’for … 我用: rails (3.0.0)shoulda (2.11.3)spork (0.8.4)rs
当我运行rspec spec / models结果就OK了.

但是当我使用spork时,每个测试应该是一个宏(像它应该是validate_presence_of(:title)}),使用失败的错误,如:undefined method’validate_presence_of’for …

我用:

rails (3.0.0)
shoulda (2.11.3)
spork (0.8.4)
rspec-rails (>= 2.0.0.beta.22)

投机/ spec_helper.rb:

require 'rubygems'
require 'spork'

Spork.prefork do
  # This file is copied to spec/ when you run 'rails generate rspec:install'
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment",__FILE__)
  require 'rspec/rails'
  require 'shoulda'
...

解决方法

我遇到过同样的问题.通过在prefork块中要求rspec / rails之后粘贴需要“shoulda / integrations / rspec2”来修复它.

您也可能希望将您的spork升级到最新版本(gem’spork’,> = 0.9.0.rc2),因为我没有在0.8.4上尝试这个修复(尽管我很确定它会工作太)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读