Topic: Test::Rails, namescaped view test cases...

I'm finally getting a chance to return to some Rails code I haven't touch in several months.   I'm bumping into a few test failures that don't make much sense to me and I was wondering if anyone can help.

I'm using Test:Rails and the failures are only showing up for three subclasses of ViewTestCase that live within their own module.

The error message I'm getting is:

  1) Error:
test_list(Admin::EventsViewTest):
NoMethodError: private method `url_for' called for #<Admin::EventsController:0x30c29b8>
    /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.5.1/lib/test/rails/view_test_case.rb:183:in `render'
    ./test/views/admin/event_view_test.rb:24:in `test_list'

The test case in question:
require 'test/test_helper'
class Admin::EventsViewTest < Test::Rails::ViewTestCase
  fixtures :competitions, :levels, :styles, :dances, :events
  def setup
    super
  end
  def test_new
    assigns[:competition]=competitions(:mit_open)
    assigns[:dances]=Dance.find :all
    render :action=>'new'
    form_url = '/competitions/2007+MIT+Open/events/create'
    assert_post_form form_url
    assert_submit form_url, "Create New Event"
    assert_select form_url, :event, :level_id, level_options
    assert_select form_url, :event, :style_id, style_options
    for a_dance in Dance.find :all do
      assert_input form_url, :checkbox, "dance_ids[#{a_dance.id}]"
    end
  end

  def test_list
    comp_events = competitions(:mit_open).events
    assigns[:events]=comp_events
    render :action=>'list'
    for an_event in comp_events do
      assert_links_to "/events/edit/#{an_event.id}", "Edit"
      assert_links_to "/events/del/#{an_event.id}", "Delete"
    end
    assert_links_to "/events/new", "Add New Event"
  end

  private
  def level_options
    levels={}
    level_list = [:mit_newcomer, :mit_beginner, :mit_intermediate, :mit_advanced,
                  :mit_prechamp, :mit_championship]
    level_list.each { | a_level| levels[levels(a_level).name]=levels(a_level).id}
    levels 
  end
  def style_options
    styles={}
    style_list = [:mit_standard, :mit_latin, :mit_smooth, :mit_rhythm]
    style_list.each { | a_style| styles[styles(a_style).name]=styles(a_style).id}
    styles 
  end
end


The error is occuring on the "render" line.  In non-namespaced viewtestcases this works as expected.  I really thought these tests used to work when I left the code in Jan.  But they failed when I started working on it today, I then updated my gems in case it was just an out-of-date set of components, but the problem persists.

Any thoughts?

Last edited by NielsenE (2007-04-21 14:34:04)

My RoR journey  -- thoughts on learning RoR and lessons learned in applying TDD and agile practices.