Sha256: 3dbab1e2e76ec4479b26ca74644e8d158d10f107f037d77b590a4f188c80494c

Contents?: true

Size: 1.23 KB

Versions: 13

Compression:

Stored size: 1.23 KB

Contents

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

describe TextFilter do
  class ReverseFilter < TextFilter
    description %{Reverses text.}
    def filter(text)
      text.reverse
    end
  end

  class CustomFilter < TextFilter
    filter_name "Really Custom"
    description_file File.dirname(__FILE__) + "/../fixtures/sample.txt"
  end

  it 'should allow description annotation' do
    ReverseFilter.description.should == %{Reverses text.}
  end
  
  it 'should allow description_file annotation' do
    CustomFilter.description.should == File.read(File.dirname(__FILE__) + "/../fixtures/sample.txt")
  end

  it 'should return an array of filter_names of all available filters' do
    TextFilter.descendants_names.should include("Markdown", "Really Custom", "Reverse", "SmartyPants", "Textile")
  end

  it 'should filter text with base filter' do
    filter = TextFilter.new
    filter.filter('test').should == 'test'
  end
  
  it 'should filter text with subclass' do
    ReverseFilter.filter('test').should == 'tset'
  end
  
  it 'should allow filter_name annotation' do
    CustomFilter.filter_name.should == 'Really Custom'
  end
  
  it 'should default filter_name annotation' do
    ReverseFilter.filter_name.should == 'Reverse'
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
radiant-1.0.1 spec/models/text_filter_spec.rb
radiant-1.0.0 spec/models/text_filter_spec.rb
radiant-1.0.0.rc5 spec/models/text_filter_spec.rb
radiant-1.0.0.rc4 spec/models/text_filter_spec.rb
radiant-1.0.0.rc3 spec/models/text_filter_spec.rb
kajam-1.0.3.rc2 spec/models/text_filter_spec.rb
radiant-1.0.0.rc2 spec/models/text_filter_spec.rb
radiant-1.0.0.rc1 spec/models/text_filter_spec.rb
radiant-rails3-0.1 spec/models/text_filter_spec.rb
radiantcms-couchrest_model-0.1.3 spec/models/text_filter_spec.rb
radiantcms-couchrest_model-0.1.2 spec/models/text_filter_spec.rb
radiantcms-couchrest_model-0.1.1 spec/models/text_filter_spec.rb
radiantcms-couchrest_model-0.1 spec/models/text_filter_spec.rb