HardlによるRuby on railsでは、以下のようなパスワード確認を書くことができますが、一連の最後のテストを操作することはできません:
#IS THIS A VALID TEST?
describe "when password confirmation is not present" do
before { @user.Password_confirmation = nil }
it { should_not be_valid }
end
だから私の質問は、これでうまくいくかということです。最後の部分で nil を " "、空白に変更しました。これは、nil に対してテストするときと同じことですか?:
describe User do
before { @user = User.new(Address:"Dummy Address",Email: "user@example.com", FirstName:"Jim", LastName:"Beam", Password:"ABC123", Password_confirmation:"ABC123", Phone:"+46000", Username:"ExampleUser", Zip:"22646" ) }
subject { @user }
puts "TEST"
it { should respond_to(:FirstName) }
it { should respond_to(:LastName) }
it { should respond_to(:Email) }
it { should respond_to(:password_digest) }
it { should respond_to(:Password) }
it { should respond_to(:Password_confirmation) }
it { should be_valid }
describe "when password is not present" do
before { @user.Password = @user.Password_confirmation = " " }
it { should_not be_valid }
end
describe "when password doesn't match confirmation" do
before { @user.Password_confirmation = "mismatch" }
it { should_not be_valid }
end
#IS THIS A VALID TEST?
describe "when password confirmation is not present" do
before { @user.Password_confirmation = " " }
it { should_not be_valid }
end