这世界到底是怎么回事??我的测试没有通过,我在整个教程中都非常小心(这次)。请告诉我为什么会弹出 remember_token 错误。
这是我的错误:失败:
1) User
Failure/Error: it { should respond_to(:remember_token) }
expected #<User id: nil, name: "Example User", email: "user@example.com", created_at: nil, updated_at: nil, password_digest: "$2a$04$HUTzfhPB9eOgNaBIwQZn/.BpGt4h/v9wgLlo.UoMoh8Q..."> to respond to :remember_token
# ./spec/models/user_spec.rb:28:in `block (2 levels) in <top (required)>'
Finished in 0.19682 seconds
22 examples, 1 failure
Failed examples:
rspec ./spec/models/user_spec.rb:28 # User
这是我的代码:
db/migrate/[时间戳]_add_remember_token_to_users.rb
class AddRememberTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :remember_token, :string
add_index :users, :remember_token
end
end
规格/模型/user_spec.rb 需要'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(:name) }
it { should respond_to(:email) }
it { should respond_to(:password_digest) }
it { should respond_to(:password) }
it { should respond_to(:password_confirmation) }
it { should respond_to(:remember_token) }
it { should respond_to(:authenticate) }
it { should be_valid }
it { should respond_to(:authenticate) }
.
.
.