1

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

ここで何が欠けているのか、なぜこれが機能しないのかについてのアイデアはありません。

4

1 に答える 1

0

あなたがしなければならないようです:

1) gem ファイルに次のように記述します。

group :test do gem 'shoulda' end

2) バンドル インストールを実行します。

于 2013-06-28T02:27:10.827 に答える