Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## unit test
- require 'test/test_helper'
- class PageTest < ActiveSupport::TestCase
- def test_invalid_if_any_field_empty
- page = Page.new
- assert !page.valid?
- assert page.errors.invalid?(:title)
- assert page.errors.invalid?(:body)
- end
- def test_valid_fields
- page = pages(:valid_page) #arg is the name of the fixture
- assert page.valid?
- end
- end
- ## fixture
- valid_page:
- id: 1
- title: Welcome Page
- permalink: welcome-page
- body: Welcome to the welcome page.
- invalid_page_short_title:
- id: 2
- title: a
- permalink: a
- body: The title is shorter than 3 characters
- valid_with_auto_permalink:
- id: 3
- title: Another page, but without a permalink
- body: No permalink is given so it should be automatically generated
Add Comment
Please, Sign In to add comment