Renamed helpers to correspond to renamed Controller classes.
[merb_radiant.git] / radiant_specs / test / unit / .svn / text-base / snippet_test.rb.svn-base
blob5e7961ddaf857471c832421c5573678ecaa77ba2
1 require File.dirname(__FILE__) + '/../test_helper'
3 class SnippetTest < Test::Unit::TestCase
4   fixtures :snippets
5   test_helper :snippets, :validations
7   # Replace this with your real tests.
8   def test_truth
9     assert_kind_of Snippet, snippets(:first)
10   end
11   
12   def setup
13     @snippet = @model = Snippet.new(VALID_SNIPPET_PARAMS)
14   end
15   
16   def test_validates_length_of
17     {
18       :name => 100,
19       :filter_id => 25
20     }.each do |field, max|
21       assert_invalid field, ('%d-character limit' % max), 'x' * (max + 1)
22       assert_valid field, 'x' * max
23     end
24   end
25   
26   def test_validates_presence_of
27     [:name].each do |field|
28       assert_invalid field, 'required', '', ' ', nil
29     end
30   end
31   
32   def test_validates_uniqueness_of
33     assert_invalid :name, 'name already in use', 'first', 'another', 'markdown'
34     assert_valid :name, 'just-a-test'
35   end
36   
37   def test_validates_format_of_name
38     assert_valid :name, 'abc', 'abcd-efg', 'abcd_efg', 'abc.html', '/', '123'
39     assert_invalid :name, 'cannot contain spaces or tabs'
40   end
41   
42   def test_filter
43     @snippet = snippets(:markdown)
44     assert_kind_of MarkdownFilter, @snippet.filter
45   end
46   
47 end