【发布时间】: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