0

Rspec テストに失敗しており、何が間違っているのか判断できません。

これが私のユーザー仕様です

require 'spec_helper'

describe User do
   before do
     @user = User.new(name: "Example User", email: "user@example.com",
          password: "foobar", password_confirmation: "foobar")
   end

   subject { @user }

   it { should respond_to(:courses)}
   it { should respond_to(:take_course!)} # this test fails
   it { should respond_to(:taking_course?)} # this test fails as well

end

これが私のuser.rbファイルです

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :name, :email, :password, :password_confirmation, :remember_me
  has_many :assignments, foreign_key: "user_id", dependent: :destroy
  has_many :courses, through: :assignments

  def take_course!
  end

  def taking_course?
  end
end

メソッドにはまだ何もありませんが、なぜ応答しないのか混乱しています。

4

1 に答える 1

0

Vimsha が指摘したように、私はテスト プリローダーとして Spork を使用していたので、単に Spork を再起動する必要がありました。

于 2013-06-25T16:21:51.853 に答える