Sha256: 811b9576ce2a50010c069662cf27a1d7a0ee82ed45647b56dc781c5cba92b90f

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 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

    it 'should optionally supply a Rack application' do
      UselessPlugin.rack_app.should be_nil
      PluginWithRackApp.rack_app.should_not be_nil
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
locomotive_plugins-1.0.0.beta9 spec/lib/locomotive/plugin_spec.rb
locomotive_plugins-1.0.0.beta8 spec/lib/locomotive/plugin_spec.rb
locomotive_plugins-1.0.0.beta7 spec/lib/locomotive/plugin_spec.rb