1 require File.dirname(__FILE__) + '/../spec_helper'
5 test_helper :validations
8 @snippet = @model = Snippet.new(snippet_params)
11 it 'should validate length of' do
15 }.each do |field, max|
16 assert_invalid field, ('%d-character limit' % max), 'x' * (max + 1)
17 assert_valid field, 'x' * max
21 it 'should validate presence of' do
22 [:name].each do |field|
23 assert_invalid field, 'required', '', ' ', nil
27 it 'should validate uniqueness of' do
28 assert_invalid :name, 'name already in use', 'first', 'another', 'markdown'
29 assert_valid :name, 'just-a-test'
32 it 'should validate format of name' do
33 assert_valid :name, 'abc', 'abcd-efg', 'abcd_efg', 'abc.html', '/', '123'
34 assert_invalid :name, 'cannot contain spaces or tabs'
37 it 'should allow the filter to be specified' do
38 @snippet = snippets(:markdown)
39 @snippet.filter.should be_kind_of(MarkdownFilter)