Unit Testing a rails 2.3.5 plugin

Posted by brad on Stack Overflow See other posts from Stack Overflow or by brad
Published on 2010-05-04T16:35:01Z Indexed on 2010/05/04 16:38 UTC
Read the original article Hit count: 286

I'm writing a new plugin for a rails 2.3.5 app. I've included an app directory (which makes it an engine) so i can easily load some extra routes. Not sure if that affects anything. Anyway, in the test directory i have two files: test_helper.rb and my_plugin_test.rb

These files were generated automatically using script/generate plugin my_plugin

When I go to vendor/plugins/my_plugin directory and run rake test they don't seem to run.

I get the following console output:

(in /Users/me/Repos/my_app/source/trunk/vendor/plugins/my_plugin)
/Users/me/.rvm/rubies/jruby-1.4.0/bin/jruby -I"lib:lib:test" "/Users/me/.rvm/gems/jruby-1.4.0/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/my_plugin_test.rb" 

So it obviously sees my test file, but none of the tests inside get run, I just get back to my console prompt. What am I missing here? I figured the generated code would work out of the box

Here are the two files

test_helper.rb

require 'rubygems'
require 'active_support'
require 'active_support/test_case'

my_plugin_test.rb

require 'test_helper'

class MyPluginTest < ActiveSupport::TestCase

  # Replace this with your real tests.
  test "the truth" do
    assert true
  end

  test "Factories are supported" do
    assert_not_nil Factory
  end
end

File structure

vendor
 - plugins
   - my_plugin
     - app
     - config
       - routes.rb
     - generators
       - my_plugin
          - some generator files.rb
     - lib
       - my_plugin.rb
       - my_plugin
         - my_plugin_lib_file.rb
     - rails
       - init.rb
     - Rakefile
     - tasks
       - my_plugin_tasks.rake
     - test
       - test_helper.rb
       - my_plugin_test.rb

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about plugins