[Ruby] testing advice

John Wulff johnwulff at gmail.com
Fri Feb 9 14:54:58 PST 2007


I'm trying to get plugin_test to work for a "mixin" plugin that provides a
few actions that make use of a few ActiveRecords.
module FeedAction
  def feed
    @items = Item.find(:all)
  end
end

I can't get the plugin_test generated test_helper to load me the proper
goods to do controller testing.  Right now I've got something like this in
feed_action_test.rb:

require File.expand_path(File.dirname(__FILE__) + "/test_helper")

class TestController < ApplicationController
  include FeedAction
  # Re-raise errors caught by the controller.
  def rescue_action(e) raise e end;
end

class CrudActionsTest < Test::Unit::TestCase
  fixtures :item

  def setup
    @controller = TestController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
  end

  def test_feed
    get :feed
  end
end

(All code snippets pasted were modified for brevity.)

Everything works (I can manipulate the AR stuff all I want) except for the
get call.  I'm hoping I'm just missing a require somewhere.

Any thoughts?  Thanks.

On 2/9/07, Geoffrey Grosenbach <boss at topfunky.com> wrote:
>
> On Fri, Feb 09, 2007 at 09:14:54AM -0800, ben wiseley wrote:
> > Since it's a very database search specific plugin I was thinking the
> > best way to do this would be to create a separate testing rails app.  Is
> > this the wrong way to go about testing plugins?
>
> I wrote a plugin that generates files for testing database-powered plugins
> against a sqlite database. You can write unit tests and make fixtures just
> like you would with a normal Rails app (but it's done inside the plugin).
>
> http://topfunky.net/svn/plugins/plugin_test/
>
> For an example in use, see
>
> http://topfunky.net/svn/plugins/ar_fixtures/
> http://topfunky.net/svn/plugins/ar_fixtures/test/ar_fixtures_test.rb
>
> Geoffrey Grosenbach
> ........................
> Blog | http://nubyonrails.com
> Podcast | http://podcast.rubyonrails.com
> Screencast | http://peepcode.com
>
> _______________________________________________
> Ruby at zenspider.com - Seattle.rb non-commercial list
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>



-- 
John Wulff    360.317.6447


More information about the Ruby mailing list