enmanuel martinez enmanuel martinez - 11 months ago 82
Ruby Question

testing devise model with minitest undefined method 'valid'

I'm trying to make a simple validity test to a user model generated through devise. my test/models/user_test.rb file looks like this

require 'test_helper'

class UserTest < ActiveSupport::TestCase

def setup
@user = User.new(email: "admin@example.com", password: "foobar" )

test should be valid do
assert @user.valid?


the error i'm getting is:

/home/ubuntu/workspace/test/models/user_test.rb:10:in `<class:UserTest>': undefined local variable or method `valid' for UserTest:Class (NameError)
from /home/ubuntu/workspace/test/models/user_test.rb:3:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport- `require'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-

I saw in this link that they manege to do a very similar test.

i completed the rails tutorial from which i learned to create a fully functional user mvc system but now i want to try to do it faster with devise.


Answer Source

You need to write: "should be valid" Look here for example link