Skip to content

Instantly share code, notes, and snippets.

@itsmeurbi
Last active June 28, 2022 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsmeurbi/bd0584da3745d111d21a6658673e4351 to your computer and use it in GitHub Desktop.
Save itsmeurbi/bd0584da3745d111d21a6658673e4351 to your computer and use it in GitHub Desktop.
require 'test_helper'
class PostTest < ActiveSupport::TestCase
test 'it is not valid without title' do
post = Post.new
refute post.valid?
assert_equal ["can't be blank"], post.errors.messages[:title]
end
test 'it is not valid without content' do
post = Post.new
refute post.valid?
assert_equal ["can't be blank"], post.errors.messages[:content]
end
test 'it is valid with title and content' do
post = Post.new(title: 'My post', content: 'My new blog post')
assert post.valid?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment