Sha256: defdb605f8d9c9daf1a30aa8f9c14b3f7e1a76f78801807683a7c07545de4f6b

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

module Locomotive
  describe Plugin do

    before(:each) do
      @config = {}
      @plugin = MyPlugin.new(@config)
      @useless_plugin = UselessPlugin.new(@config)
    end

    it 'should call custom initialization methods' do
      @plugin.custom_attribute.should == 'Value'
    end

    it 'should call the given block before custom initialization methods' do
      @plugin = MyPlugin.new(@config) do |obj|
        obj.custom_attribute.should be_nil
      end
      @plugin.custom_attribute.should_not be_nil
    end

    it 'should have filter callbacks' do
      @plugin.expects(:my_method1)
      @plugin.expects(:my_method2)
      @plugin.expects(:my_method3)
      @plugin.run_callbacks(:filter) do
      end
    end

    it 'should optionally return a liquid drop' do
      @plugin.to_liquid.class.should == MyPlugin::MyDrop
      @useless_plugin.to_liquid.should be_nil
    end

    it 'should optionally return liquid filters' do
      MyPlugin.liquid_filters.should == MyPlugin::Filters
      UselessPlugin.liquid_filters.should be_nil
    end

    it 'should optionally return liquid tags' do
      UselessPlugin.liquid_tags.should == {}
      PluginWithTags.liquid_tags.should == {
        :paragraph => PluginWithTags::Paragraph,
        :newline => PluginWithTags::Newline
      }
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotive_plugins-1.0.0.beta6 spec/lib/locomotive/plugin_spec.rb
locomotive_plugins-1.0.0.beta5 spec/lib/locomotive/plugin_spec.rb