dimanche 10 décembre 2017

Rails test error: no such table: files_users: DELETE FROM "files_users"

Hello I am studying rails on ruby and am completely new to coding itself. I apologize in advanced if this is a super easy problem to fix.

I keep getting an error on the following title when I run rails test. I am incorporating fixtures to integration tests and I am quite unsure what these errors mean. If I incorporate test, is there another step to take?

I have 11 errors based on the same but brought one for example:

    Error:
    UserTest#test_name_is_Bob_Builder:
    ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: files_users: DELETE FROM "files_users"


bin/rails test test/models/user_test.rb:12

On my users.yml:

<% salt = BCrypt::Engine.generate_salt %>
<% password = 'abc123' %>

bob:
  name: 'Bob Builder'
  email: 'bob@builder.com'
  password_hash: <%= BCrypt::Engine.hash_secret(password, salt) %>
  password_salt: <%= salt %>

On my user_test.rb

require 'test_helper'

class UserTest < ActiveSupport::TestCase
  test 'can create user' do
    before = User.all.size
    User.create
    after = User.all.size

    assert after = before + 1
  end

  test 'name is Bob Builder' do
    user = users(:bob)
    assert user.name == 'Bob Builder'
  end

  test 'can authenticate user' do
    user = User.authenticate('bob@builder.com', 'abc123')
    assert user == users(:bob)
  end
end

Aucun commentaire:

Enregistrer un commentaire