Skip to content

Instantly share code, notes, and snippets.

@katatsu12
Created February 25, 2017 10:53
Show Gist options
  • Save katatsu12/09de967eca67a29795902c12a84faa47 to your computer and use it in GitHub Desktop.
Save katatsu12/09de967eca67a29795902c12a84faa47 to your computer and use it in GitHub Desktop.
require "rails_helper"
RSpec.describe Article, :type => :model do
it "validates title" do
article = Article.new(title: '')
article.valid?
article.errors[:title]
end
it "validates lenghr" do
article = Article.new(title: 'as')
article.valid?
article.errors[:title]
end
it "Article has many a comments" do
comment = Comment.new
article = Article.new
article.comments << comment
expect(comment.article).to be article
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment