【问题标题】:NoMethodError: Undefined method `failure_message` - ShouldaNoMethodError:未定义的方法`failure_message` - 应该
【发布时间】:2013-04-19 14:22:03
【问题描述】:

我正在尝试使用Shoulda 来测试我的用户类,如下所示:

user_test.rb

require 'test_helper'
include Devise::TestHelpers

class UserTest < Test::Unit::TestCase
  should have_many(:holidays)
  should have_many(:hopsital_bookings)
  should have_and_belong_to_many(:roles)
  should belong_to(:hospital)

end 

用户.rb

  belongs_to :hospital
  belongs_to :department
  has_many :holidays
  has_many :hospital_bookings
  has_and_belongs_to_many :roles

当我运行rake test 时,我得到以下输出:Imgur

我在这里缺少的任何想法以及为什么这不起作用,因为它应该!

【问题讨论】:

  • 您的test_helper.rb 中有什么内容?

标签: ruby-on-rails-3 ruby-on-rails-3.1 shoulda


【解决方案1】:

看来你必须:

1) 放入您的 gem 文件:

组:测试做 宝石“应该” 结束

2) 运行捆绑安装

【讨论】:

    猜你喜欢
    • 2013-04-24
    • 2015-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-01
    • 2019-06-12
    • 2013-11-14
    • 2021-07-07
    相关资源
    最近更新 更多