Sha256: 95f86cacf705c3205dd3ddca8ad531abf9dbce35287eee8dcf750e478cbcf105

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 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, ('this must not be longer than %d characters' % max), 'x' * (max + 1)
      assert_valid field, 'x' * max
    end
  end
  
  it 'should validate presence of' do
    [:name].each do |field|
      assert_invalid field, 'this must not be blank', '', ' ', nil
    end
  end
  
  it 'should validate uniqueness of' do
    assert_invalid :name, 'this name is 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

7 entries across 7 versions & 3 rubygems

Version Path
radiant-rails3-0.1 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.4 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.3 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.2 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1.1 spec/models/snippet_spec.rb
radiantcms-couchrest_model-0.1 spec/models/snippet_spec.rb
radiant-0.9.1 spec/models/snippet_spec.rb