dry_plugin_test
- Author
-
Hendrik Volkmer - hvolkmer (at) imedo.de
- Copyright
-
Copyright © 2008 imedo GmbH
- Licence
-
MIT
- Git
- Bugs
-
No dedicated bug tracker yet - Email us or just send pull requests
Makes your plugin tests dry and isolates plugin tests from you real app.
Dependencies
-
Rails 2.0.2 (should work also with 1.2)
-
sqlite3 - www.sqlite.org/
Installation
The easiest way to install this gem is directly via the github gem repository:
$ sudo gem install imedo-dry_plugin_test_helper -s http://gems.github.com
Or
download the source code and build the gem yourself
$ git clone git://github.com/imedo/dry_plugin_test_helper.git
$ cd dry_plugin_test_helper
$ rake
$ sudo gem install pkg/dry_plugin_test_helper-0.0.3.gem
Usage
In your plugin test helper use these lines:
require 'rubygems'
require 'dry_plugin_test_helper'
PluginTestEnvironment.init_env(File.dirname(__FILE__))
This sets up the test environment which means you have a stub rails app with you plugin loaded and also the following models:
-
Article: belongs_to :author, has_many :comments
-
Author: has_many :articles
-
Comment: belongs_to :articles, belongs_to :user
-
User: has_many :comments
The models will be added to a sqlite in memory database for fast testing.
You can add your own models using a migration in your test directory like this:
PluginTestEnvironment::Migration.setup do
create_table "animals", :force => true do |t|
t.column "name", :string
t.column "age", :integer
end
end
If you don’t want the standard models you can initialize the test environment like this:
PluginTestEnvironment.init_env(File.dirname(__FILE__), false)
TODO
-
Tests for the test gem itself
-
support for RSpec and other testing frameworks (might already work - haven’t tried it)
-
Automatic Rails version discovery
-
Clean up / strip down rails env to bare minimum