Running Tests in Ruby

0

I need to run some tests on ruby, and although I have followed the steps of the documentation I always get the same mistakes. I followed these steps:

-rake db:test:load
-rake db:test:preparate

I already have my "test" folder and in models the tests of all the devises that I have created for my application. When I decompose the code: test "the truth" do    assert true   end and I run the test like this: rails test test / models / contacto_test.rb I get this error:

  

Error: Contact Test # test_the_truth: ActiveRecord :: RecordNotUnique:   SQLite3 :: ConstraintException: UNIQUE constraint failed: users.email:   INSERT INTO "users" ("created_at", "updated_at", "id") VALUES   ('2018-07-28 21: 14: 19.244199', '2018-07-28 21: 14: 19.244199',   298486374)

test / models / contacto_test.rb:

require 'test_helper'

class ContactoTest < ActiveSupport::TestCase
  test "the truth" do
    assert true
  end

  #test "guarda_usuario" do
    #contacto = Contacto.new ({nombre:'pepito', apellidos: 'lopez garcia', edad: '56'})
    #assert contacto.save
  #end 
end

Apparently something related to the database, but I do not know what it means. I always get the same error, it does not matter what test happens to me, whether to pass it or not and the same way that model tries it, I always get the same error. Can someone help me please? Thanks in advance

    
asked by mantisa 28.07.2018 в 23:17
source

1 answer

0

The test file is fine, the problem should then be in your fixtures . Open the file test / fixtures / contacts.yml and make sure to update the records that have been generated, or comment them:

# one: {}
#   ...
#
# two: {}
#   ...
    
answered by 29.07.2018 / 21:58
source