New to rails and just getting started learning testing. We're having a problem that probably has a simple answer that has us stumped.
We have wrote some code and got it working in development (just static code and a login system w/ Devise). The only test cases in our file were generated by rails, for example:
test "should get about" do
get :about
assert_response :success
end
However, when we run bundle exec rake test
, to our surprise, we fail every single test.
10 runs, 0 assertions, 0 failures, 10 errors, 0 skips
Each test has the same error:
ActiveRecord::StatementInvalid: PG::NotNullViolation: ERROR: null value in column "email" violates not-null constraint
DETAIL: Failing row contains (980190962, null, 2015-10-27 09:40:30, 2015-10-27 09:40:30).
: INSERT INTO "leads" ("created_at", "updated_at", "id") VALUES ('2015-10-27 09:40:30', '2015-10-27 09:40:30', 980190962)
By reading that error, it seems like there is some record in our leads
table without an email. E-mail was a field created later after a migration. However, looking through psqlAdmin, every row has an e-mail. Furthermore, if we look in the console after loading the pages in chrome, there are no errors.
Even the most basic test is failing with the same error:
test "the truth" do
assert true
end
My only guess is that there is some default seeding going on, and it is trying to insert a field into leads without an e-mail. However, seeds.rb
is completely blank.
Here is the start of my call in terminal:
Macintosh-2:triplanding Calvino$ bundle exec rake test
Run options: --seed 15348
# Running:
EEEEEEEEEE
Finished in 0.108843s, 91.8753 runs/s, 0.0000 assertions/s.
- Why are these tests failing?
- Why is the
leads
even involved in a test like assert true.
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire