Created
January 7, 2015 18:20
-
-
Save pmichaeljones/f2d03213bf7db6511ea0 to your computer and use it in GitHub Desktop.
Passing Validation Errors
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
class Video < ActiveRecord::Base | |
belongs_to :category , foreign_key: 'category_id' | |
validates :title, presence: true | |
validates :description, presence: true | |
end | |
--------- Different Code Below. Same Gist Though ---------- | |
it "requires a title" do | |
harry = Video.create(title: nil, description:"A touching story.", category_id: 1) | |
expect(harry.errors.full_messages[0]).to eq("Title can't be blank") | |
end | |
it "requires a description" do | |
harry = Video.create(title:"When Harry Met Sally", description: nil, category_id: 1) | |
expect(harry.errors.full_messages[0]).to eq("Description can't be blank") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment