Skip to content
Browse files

Adicionada validações nos artigos

  • Loading branch information...
1 parent ddfb1d5 commit 520fd18a56e467322dd3fe228a5d2b450ce40d46 @rafaelfranca committed May 9, 2010
Showing with 16 additions and 2 deletions.
  1. +2 −0 app/models/article.rb
  2. +14 −2 spec/models/article_spec.rb
View
2 app/models/article.rb
@@ -1,2 +1,4 @@
class Article < ActiveRecord::Base
+ validates :title, :presence => true
+ validates :body, :presence => true
end
View
16 spec/models/article_spec.rb
@@ -1,6 +1,18 @@
require 'spec_helper'
describe Article do
- it "deveria ter um titulo"
- it "deveria ter um texto"
+ it "deveria ser valido com atributos validos" do
+ article = Factory.build(:article)
+ article.should be_valid
+ end
+
+ it "deveria ter um titulo" do
+ article = Factory.build(:article, :title => nil)
+ article.should_not be_valid
+ end
+
+ it "deveria ter um texto" do
+ article = Factory.build(:article, :body => nil)
+ article.should_not be_valid
+ end
end

0 comments on commit 520fd18

Please sign in to comment.
Something went wrong with that request. Please try again.