我正在尝试运行我的简单 UserTest
require 'test_helper'
class UserTest < ActiveSupport::TestCase
fixtures :users
test "user attributes must not be empty" do
user = users(:valid_user)
assert user.invalid?
assert user.errors[:nome].any?
assert user.errors[:cognome].any?
assert user.errors[:localita].any?
assert user.errors[:provincia].any?
assert user.errors[:nazione].any?
assert user.errors[:cap].any?
assert user.errors[:indirizzo].any?
assert user.errors[:civico].any?
assert user.errors[:telefono].any?
assert user.errors[:mail].any?
assert user.errors[:username].any?
assert user.errors[:password].any?
end
end
有了这个 users.yaml
valid_user:
nome: prova
cognome: prova
localita: prova
provincia: prova
nazione: prova
cap: 00000
indirizzo: strada di prova
civico: 1
telefono: 1111111111
mail: prova@prova.com
username: prova
password: prova
但它返回此错误:
加载套件 /var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_test_loader 开始 F 0.182523 秒内完成。
1)失败:test_user_attributes_must_not_be_empty(UserTest)[../unit/user_test.rb:10]:断言失败,没有给出消息。
1 次测试,2 次断言,1 次失败,0 次错误,0 次跳过
有什么问题?