为什么这个测试不能通过?我使用devise进行身份验证。
user.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发布于 2013-03-05 12:13:07
您必须指定一个主题才能在RSpec中调用'it‘。例如,您可以添加
主题{ @user }
在你的“做之前”代码块之后。
以后,一定要复制错误消息,这样每个人都知道去哪里看!
https://stackoverflow.com/questions/15213634
复制相似问题