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
Matthew McCulloch
5,341 PointsWriting tests - Where is the devise inherited user class?
Decided I wanted to do some more tests at the end of the Writing tests section, and got an unexpected pass on the first one I ran.
test "a user should enter an email" do
user = User.new
assert !user.save
assert !user.errors[:email].empty?
end
I checked the user.rb file and I have no validates markup on the email attribute, is this an instance of convention over code where Ruby assumes attributes named email are required? Just started thinking about it and is User an inherited class from devise?
That must be it, so my real question is where are the devise base classes or are they some type of compiled code somewhere? And should unit tests be written on the attributes that devise defined such as email/password?
1 Answer
Jason Seifer
Treehouse Guest TeacherHey Matthew McCulloch great question! I recommend exploring the devise code in https://github.com/plataformatec/devise/tree/master/lib/devise/models to check out how it all works :)