Sha256: 13f904cfcdccb3b0674293531bec369cff182d30f771d5b7ae83c37af8fe2263

Contents?: true

Size: 1009 Bytes

Versions: 106

Compression:

Stored size: 1009 Bytes

Contents

require 'test_helper'

module MyPlugin
  def self.configure(model)
    model.class_eval { attr_accessor :from_configure }
  end

  module ClassMethods
    def class_foo
      'class_foo'
    end
  end

  module InstanceMethods
    def instance_foo
      'instance_foo'
    end
  end
end

class PluginsTest < Test::Unit::TestCase
  context "plugin" do
    setup do
      @document = Class.new do
        extend MongoMapper::Plugins
        plugin MyPlugin
      end
    end

    should "include instance methods" do
      @document.new.instance_foo.should == 'instance_foo'
    end

    should "extend class methods" do
      @document.class_foo.should == 'class_foo'
    end

    should "pass model to configure" do
      @document.new.should respond_to(:from_configure)
    end

    should "default plugins to empty array" do
      Class.new { extend MongoMapper::Plugins }.plugins.should == []
    end

    should "add plugin to plugins" do
      @document.plugins.should include(MyPlugin)
    end
  end
end

Version data entries

106 entries across 106 versions & 12 rubygems

Version Path
mongo_mapper-unstable-2010.07.15 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.14 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.13 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.12 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.09 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.08 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.07 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.06 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.05 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.02 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.07.01 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.06.30 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.06.29 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.06.28 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.06.25 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.06.24 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.06.23 test/unit/test_plugins.rb
mongo_mapper-0.8.2 test/unit/test_plugins.rb
mongo_mapper-0.8.1 test/unit/test_plugins.rb
mongo_mapper-0.8.0 test/unit/test_plugins.rb