I want to build a plugin by extracting some code from an existing app. I figured the first thing I should do is get comfortable working on a plugin, so I generated a Rails 2.3.3 app, and from inside that, I generated a plugin. Before doing anything else, I thought I would try to run the plugin’s generated test. The file loads fine - but the test isn’t run. I can prove that by adding a couple of “puts” statements to the test.
I can’t figure out why the file is found - but the test does not run. What I started with is below. Grasping at straws, I also tried current ActiveSupport out of the picture by having the test inherit directly from Test::Unit::TestCase and using the older “def test_truth; assert true; end” syntax. But that didn’t change anything. There are no errors; the tests just get silently ignored. How can this be?
The steps I took:
$ rails generate bar
$ cd bar
$ script/generate plugin MyPlugin
$ cd vendor/plugin/my_plugin
$ rake test
RAILS version 2.3.3
Ruby 1.8.6 on MacOs X
class MyPluginTest < ActiveSupport::TestCase
puts “In MyPluginTest file”
Replace this with your real tests.
test “the truth” do
puts “In truth test”
puts “vendor/plugins/my_plugin/test/test_helper is being read”
$ rake test
/usr/local/bin/ruby -I"lib:lib:test" “/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb” “test/my_plugin_test.rb”
vendor/plugins/my_plugin/test/test_helper is being read
In MyPluginTest file