I have developed some tests in Rails that work fine. Then I added:
- In model file: has_secure_password
- In Gem file: gem 'bcrypt', '3.1.7' (after bundle install it shows up in Gemfile.lock)
- I added password_digest as string to the migration file (and after migrating it indeed shows up in schema.rb)
And I added password and password_confirmation to setup in the test file:
def setup
@user = User.new(email: "user@example.com",
username: "example user",
firstname: "Allan",
location: "Europe",
password: "foobar",
password_confirmation: "foobar")
end
Now when I run rake test
I get errors saying:
NoMethodError: undefined method 'password_digest=' for #<User:0x00000002f9c020> test/models/user_test.rb:6:in 'setup'.
Line 6 refers to the line @user = User.new ...
So it seemed to have implemented the gem and additional column correctly, and yet I get this error message. Does anyone have an idea what could be the cause?