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 回答