Sha256: fa394e4d1b52dcf41900ee169a1b45e34ef5c79d9bf5c5fda90581316cdbf707

Contents?: true

Size: 829 Bytes

Versions: 14

Compression:

Stored size: 829 Bytes

Contents

require 'test_helper'

module MyPlugin
  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 "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

14 entries across 14 versions & 2 rubygems

Version Path
mongo_mapper-unstable-2010.1.22 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.1.21 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.1.20 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.1.19 test/unit/test_plugins.rb
jmonteiro-mongo_mapper-0.1.7 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.1.18 test/unit/test_plugins.rb
jmonteiro-mongo_mapper-0.1.6 test/unit/test_plugins.rb
jmonteiro-mongo_mapper-0.1.5 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.1.17 test/unit/test_plugins.rb
jmonteiro-mongo_mapper-0.1.4 test/unit/test_plugins.rb
jmonteiro-mongo_mapper-0.1.2 test/unit/test_plugins.rb
jmonteiro-mongo_mapper-0.1.1 test/unit/test_plugins.rb
jmonteiro-mongo_mapper-0.1.0 test/unit/test_plugins.rb
mongo_mapper-unstable-2010.1.12 test/unit/test_plugins.rb