ChiliProject is not maintained anymore. Please be advised that there will be no more updates.
We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.
Sample plugin doesn't contain tests (Feature #854)
Description
One of the problems I'm finding with Redmine/Chiliproject is that implementing a plugin using TDD seems like an obscure black art. The tutorials online I found (including the Redmine Plugin Tutorial and its empty Chiliproject Equivalent) don't mention tests at all; they pretty much encourage cowboy development.
I have tried to run tests on several plugins I found, but I soon hit problems:- There doesn't seem to be a standarized way of specifying dependencies in plugins. I had to hit errors "as I went". That was ok 3 years ago, but with rvm, bundler & company, even ruby 1.8.x, we have ways to cope with that. Am I missing something on that regard?
- I don't think the "general and recommended strategy" for making tests in plugins is written in any place. Some of the plugins I found seemed to require to be "embedded into a host redmine app" in order to work. Is that the case for all plugins?
I'm sorry if I sound a bit frustrated. I spent 3 hours yesterday just trying to make Redmine Join Project to run its tests correctly, but I couldn't manage to make them run.
I think having an opinionated and exemplary test configuration in the Sample Plugin would help and encourage plugin devs to write better code. And would also help detecting incompatibilities/etc much easier.
Is there a recommended plugin with easy-to-run and complete tests out there that I can "spy" on? Maybe I can prepare a pull request for the sample project myself.
Associated revisions
Adds permissions to let users edit and/or delete their messages (#854, patch by Markus Knittig with slight changes).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2019 e93f8b46-1217-0410-a6f0-8f06a7374b81
History
Updated by Eric Davis at 2012-02-27 07:03 am
Enrique GarcÃa Cota wrote:
I think having an opinionated and exemplary test configuration in the Sample Plugin would help and encourage plugin devs to write better code. And would also help detecting incompatibilities/etc much easier.
Agreed.
Is there a recommended plugin with easy-to-run and complete tests out there that I can "spy" on? Maybe I can prepare a pull request for the sample project myself.
Most of my plugins have tests. Try checking my GitHub for the most recently updated plugin. A few tips:
- Any of my plugins that have a
spec/
directory will not have working tests. Those were early plugins that used RSpec which proved to be more trouble than it was worth. More recent plugins have atest/
directory. - Any of my plugins prefixed with "chiliproject" are more current.
- Any of my plugins with a
Gemfile
in the root of the plugin are compatible with ChiliProject 2.x. - Install the plugin and then in ChiliProjects root run
bundle install
. This will pick up the pluginGemfile
. - To run the tests, make sure you run them in the plugins root. You might need to install my helper gem
redmine_plugin_support
. Runningrake test
should be all you need to do.
I just looked for you and my message bar plugin is a simple, current, and tested plugin with no extra dependencies. If you can get the tests running and passing for it, you can move onto the more complex plugins.
- Assignee deleted (
Eric Davis) - Category set to Documentation
Updated by Jan Vlnas at 2012-03-21 09:01 pm
I am looking into plugins TDD too but without any luck. Maybe there is something different in the development version of ChiliProject (running from master). Or it's because I am using Ruby 1.9.
Here's what I did:
- Cloned Eric's Message Bar to vendor/plugins; works fine in the development installation
- Installed
redmine_plugin_support
gem - Removed
:metrics
from plugin.tasks in plugin's Rakefile; that's because ofmetric_fu
depends onrcov
which is MRI 1.8-only. - Ran
rake test
from plugin's directory – fails with rather cryptic error`require': can't convert Array into String (TypeError)
– see the full trace rake test
from the vendor/plugins directory runs the whole test suite;rake test:engines:all
(as recommended on the afformentioned Redmine's Plugin Tutorial) seems to run the plugin's test suite which fails with the same error.
Am I doing something wrong? Maybe this is a problem of this one specific plugin, on the other hand, this plugin would be a great example if the test was working.
Updated by Jan Vlnas at 2012-03-21 10:21 pm
Alright, it seems that source of the problem was this line in plugin's test_helper
Engines::Testing.set_fixture_path
Since this plugin doesn't use fixtures, I've fixed the test suite by commenting out the offending line. However there's a bug in Engines::Testing which adds an array to a $LOAD_PATH
causing require to fail. I'll open a separate issue for this.