Created
June 28, 2022 03:59
-
-
Save itsmeurbi/e55e310b958bd7f1246ebc66a2638586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class CommentTest < ActiveSupport::TestCase | |
test 'it is not valid without a post' do | |
comment = Comment.new | |
refute comment.valid? | |
assert_equal ['must exist'], comment.errors.messages[:post] | |
end | |
test 'it is not valid without content' do | |
comment = Comment.new | |
refute comment.valid? | |
assert_equal ["can't be blank"], comment.errors.messages[:content] | |
end | |
test 'it is valid with a post and content' do | |
post = Post.new(title: 'My post', content: 'My new blog post') | |
comment = Comment.new(post: post, content: 'Nice post!') | |
assert comment.valid? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment