Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Freddy Heppell
Freddy Heppell
9,753 Points

I've got a validation error...

I'm watching the video :Build a Simple Ruby on Rails Application > Writing Tests > Fixtures.

In the video Jason runs his code with no errors however I get four:

test_a_user_should_enter_a_first_name(UserTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: table users has no column named password: INSERT INTO "users" ("first_name", "last_name", "email", "profile_name", "password", "password_confirmation", "created_at", "updated_at", "id") VALUES ('Test', 'Test', 'test@test.com', 'testtest', 'letmein', 'letmein', '2013-06-23 09:58:50', '2013-06-23 09:58:50', 118750655)

test_a_user_should_enter_a_last_name(UserTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: table users has no column named password: INSERT INTO "users" ("first_name", "last_name", "email", "profile_name", "password", "password_confirmation", "created_at", "updated_at", "id") VALUES ('Test', 'Test', 'test@test.com', 'testtest', 'letmein', 'letmein', '2013-06-23 09:58:50', '2013-06-23 09:58:50', 118750655)

test_a_user_should_enter_a_profile_name(UserTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: table users has no column named password: INSERT INTO "users" ("first_name", "last_name", "email", "profile_name", "password", "password_confirmation", "created_at", "updated_at", "id") VALUES ('Test', 'Test', 'test@test.com', 'testtest', 'letmein', 'letmein', '2013-06-23 09:58:50', '2013-06-23 09:58:50', 118750655)

test_a_user_should_have_a_unique_profile_name(UserTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: table users has no column named password: INSERT INTO "users" ("first_name", "last_name", "email", "profile_name", "password", "password_confirmation", "created_at", "updated_at", "id") VALUES ('Test', 'Test', 'test@test.com', 'testtest', 'letmein', 'letmein', '2013-06-23 09:58:50', '2013-06-23 09:58:50', 118750655)

My user_test.rb contains

require 'test_helper'

class UserTest < ActiveSupport::TestCase
     test "a user should enter a first name" do 
    user = User.new
    assert !user.save
    assert !user.errors[:first_name].empty?
 end

 test "a user should enter a last name" do 
    user = User.new
    assert !user.save
    assert !user.errors[:last_name].empty?
    end

 test "a user should enter a profile name" do 
    user = User.new
    assert !user.save
    assert !user.errors[:profile_name].empty?
 end

 test "a user should have a unique profile name" do 
    user = User.new
    user.profile_name = 'testtest'
    user.email = 'test@test.com'
    user.first_name = 'Test'
    user.last_name = 'Test'
    user.password = 'letmein'
    user.password_confirmation = 'letmein'

    assert !user.save
    assert !user.errors[:profile_name].empty?
 end
end

And my users.yml

freddy:
  first_name: "Test"
  last_name: "Test"
  email: "test@test.com"
  profile_name: "testtest"
  password: "letmein"
  password_confirmation: "letmein"

Why is this happening?

1 Answer

Freddy Heppell
Freddy Heppell
9,753 Points

Ah, just read teachers notes

If you get an error like the following while running your tests:

ActiveRecord::StatementInvalid: SQLite3::SQLException: table users has no column named password Try opening up the test/fixtures/users.yml file and remove the password and password_confirmation lines.