为什么这个测试没有通过?我使用设计进行身份验证。
用户.rb
validates :username, presence: true, :length => { :minimum => 2 }
user_spec.rb
require 'spec_helper'
describe User do
before do
@user = User.new(username: "Example User", email: "user@example.com",
password: "foobar", password_confirmation: "foobar")
end
describe "name" do
before { @user.username="test" }
it { should be_valid }
end
end