Skip to content

Instantly share code, notes, and snippets.

@katatsu12
Created February 25, 2017 18:24
Show Gist options
  • Save katatsu12/06288b5468d96b062fcf19400736d411 to your computer and use it in GitHub Desktop.
Save katatsu12/06288b5468d96b062fcf19400736d411 to your computer and use it in GitHub Desktop.
require "rails_helper"
RSpec.describe Article, :type => :model do
it "Validation Error title" do
article = Article.new(title: '')
article.valid?
article.errors[:title]
end
it "Validation Error lenghr" do
article = Article.new(title: 'as')
article.valid?
article.errors[:title]
end
it "is valid with valid attributes" do
expect(Article.new(title: 'Anything')).to be_valid
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