Sha256: 65947ff48d885ca5d2fdeeaeb0e28c740905a228a89a8d8e2d78a74ca7f357c5

Contents?: true

Size: 1.05 KB

Versions: 17

Compression:

Stored size: 1.05 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Snippet do
  dataset :snippets
  test_helper :validations
  
  before :each do
    @snippet = @model = Snippet.new(snippet_params)
  end
  
  it 'should validate length of' do
    {
      :name => 100,
      :filter_id => 25
    }.each do |field, max|
      assert_invalid field, ('%d-character limit' % max), 'x' * (max + 1)
      assert_valid field, 'x' * max
    end
  end
  
  it 'should validate presence of' do
    [:name].each do |field|
      assert_invalid field, 'required', '', ' ', nil
    end
  end
  
  it 'should validate uniqueness of' do
    assert_invalid :name, 'name already in use', 'first', 'another', 'markdown'
    assert_valid :name, 'just-a-test'
  end
  
  it 'should validate format of name' do
    assert_valid :name, 'abc', 'abcd-efg', 'abcd_efg', 'abc.html', '/', '123'
    assert_invalid :name, 'cannot contain spaces or tabs'
  end
  
  it 'should allow the filter to be specified' do
    @snippet = snippets(:markdown)
    @snippet.filter.should be_kind_of(MarkdownFilter)
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.2.2 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.2.1 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.2 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.9 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.8 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.7 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.6 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.5 spec/models/snippet_spec.rb
radiant-0.7.2 spec/models/snippet_spec.rb
radiant-0.8.2 spec/models/snippet_spec.rb
radiant-0.9.0.rc2 spec/models/snippet_spec.rb
radiant-rc-0.9.0 spec/models/snippet_spec.rb
radiant-0.8.1 spec/models/snippet_spec.rb
radiant-0.7.0 spec/models/snippet_spec.rb
radiant-0.8.0 spec/models/snippet_spec.rb
radiant-0.7.1 spec/models/snippet_spec.rb