Sha256: b8bee00aff9fce18401f244ea4b3c4dd2efb640a42499d7033199972b558668f

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

require '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("Pseudo Markdown", "Pseudo Textile", "Really Custom", "Reverse")
  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

8 entries across 8 versions & 1 rubygems

Version Path
radiant-1.1.4 spec/models/text_filter_spec.rb
radiant-1.1.3 spec/models/text_filter_spec.rb
radiant-1.1.2 spec/models/text_filter_spec.rb
radiant-1.1.1 spec/models/text_filter_spec.rb
radiant-1.1.0 spec/models/text_filter_spec.rb
radiant-1.1.0.rc1 spec/models/text_filter_spec.rb
radiant-1.1.0.beta spec/models/text_filter_spec.rb
radiant-1.1.0.alpha spec/models/text_filter_spec.rb