Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Entry model
- class Entry < ActiveRecord::Base
- validates :title, :description, presence: true
- validates :title, uniqueness: true
- validates :image_url, allow_blank: true, format: {
- with: %r{\.(gif|jpg|png)$}i,
- message: 'must be a URL for GIF, JPG or PNG image.'
- }
- end
- # Entry test
- require 'test_helper'
- class EntryTest < ActiveSupport::TestCase
- test 'entry attributes must not be empty' do
- entry = Entry.new
- assert entry.invalid?
- assert entry.errors[:title].any?
- assert entry.errors[:description].any?
- assert entry.errors[:image_url].any?
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement