How to test an acts_as plugin?

I’m currently writing my first plugin, which is in the acts_as style,
but I can’t for the life of me work out how to get the testing working.

The plugin is called ‘acts_as_task_list’, and I want to create a model
just for testing this, so my test currently looks like this:

require ‘test/unit’
require ‘active_record’

This model is just for testing the plugin.

class Contract < ActiveRecord::Base
acts_as_task_list
end

The first bit doesn’t work, so I haven’t got as far

as this bit yet.

class ActsAsTaskListTest < Test::Unit::TestCase

Replace this with your real tests.

def test_this_plugin
flunk
end
end

As I expected, this test explodes because Ruby hasn’t loaded up the
plugin and included the acts_as_task_list into ActiveRecord::Base, but I
don’t seem to be able to find out how to make this happen. I’ve tried
requiring the init.rb file for the plugin, but Ruby complains that it
can’t find the source file.

Although there’s plenty of help from Google, here and the Wiki on
writing a plugin, I can’t find a single piece of information to tell me
what I’m doing wrong in the testing. If anyone can help it would be much
appreciated.

Many thanks.

Jonathan T. wrote:

I’m currently writing my first plugin, which is in the acts_as style,
but I can’t for the life of me work out how to get the testing working.

The plugin is called ‘acts_as_task_list’, and I want to create a model
just for testing this, so my test currently looks like this:

require ‘test/unit’
require ‘active_record’

This model is just for testing the plugin.

class Contract < ActiveRecord::Base
acts_as_task_list
end

The first bit doesn’t work, so I haven’t got as far

as this bit yet.

class ActsAsTaskListTest < Test::Unit::TestCase

Replace this with your real tests.

def test_this_plugin
flunk
end
end

As I expected, this test explodes because Ruby hasn’t loaded up the
plugin and included the acts_as_task_list into ActiveRecord::Base, but I
don’t seem to be able to find out how to make this happen. I’ve tried
requiring the init.rb file for the plugin, but Ruby complains that it
can’t find the source file.

Although there’s plenty of help from Google, here and the Wiki on
writing a plugin, I can’t find a single piece of information to tell me
what I’m doing wrong in the testing. If anyone can help it would be much
appreciated.

Many thanks.

I answered my own question by looking at the testing in the
acts_as_classifiable plugin, inderting these two require lines at line 3
of the code lets this code run:

require File.join(File.dirname(FILE), ‘…/lib/acts_as_task_list’)
require File.join(File.dirname(FILE), ‘…/init’)