0
我正在通过Michael Hartl书。我在第6.3.3节。我明白我们正在努力完成的。但是,对我来说,两个这样的规格似乎是测试同样的事情:Hartl Ch 6规格说明
从user_spec.rb:http://ruby.railstutorial.org/chapters/modeling-users#code-authenticate_spec
describe "return value of authenticate method" do
before { @user.save }
let(:found_user) { User.find_by_email(@user.email) }
describe "with valid password" do
it { should == found_user.authenticate(@user.password) }
end
describe "with invalid password" do
let(:user_for_invalid_password) { found_user.authenticate("invalid") }
it { should_not == user_for_invalid_password } #1
specify { user_for_invalid_password.should be_false } #2
end
end
规格是1和2不能同时检测了DB不应该验证用户如果他的密码不正确?这些测试如何不同?
我想你误解了我指的是哪两个规格。我不是在谈论“有效密码”。我正在谈论“无效密码”中的两个规格(请参见编号)。 – tir38 2013-06-01 16:25:13