I’m trying to run my simple 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
with this 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
but it returns this error:
Loaded suite
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started F Finished in 0.182523 seconds.1) Failure: test_user_attributes_must_not_be_empty(UserTest)
[../unit/user_test.rb: 10]: Failed assertion, no message given.1 tests, 2 assertions, 1 failures, 0 errors, 0 skips
What’s the problem?
well, Failed assertion is
which means that there are no errors on attribute :nome
why are you asserting that there should be errors on that attribute is a complete mystery to me
maybe you wanted to use
errors[:nome].none??