Testing template components

Hi,

I’m plowing through the template section of “Agile Rails”, specifically
the
stuff starting on P. 364. What is a good strategy for testing
components?

My initial thought is to mimic the Rails application “test” directory.
No
problem.

Next copy the setup method, and set it up like so -

class SidebarControllerTest < Test::Unit::TestCase
def setup
@controller = Navigation::Sidebar.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end

def test_setup
assert true
end
end

Nope, that throws an error that makes me think I am headed in the wrong
direction-

  1. Error:
    test_get_menu(SidebarControllerTest):
    NoMethodError: undefined method new' for Navigation::Sidebar:Dependencies::LoadingModule functional/sidebarTest.rb:9:insetup_without_fixtures’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:523:in
    setup' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:521:insetup’

Here is the controller if that is of interest (basically copied out of
the
book)

class Navigation::SidebarController < ActionController::Base
uses_component_template_root
Link = Struct.new(:name, :url)
def self.find(*ignored)
[Link.new(“people”,"/person"),
Link.new(“home”,"/")]
end

def menu
@links = self.class.find(:all)
render(:layout => false)
end
end

So, what is a good way to test components? The one requirment I see is
that
the tests should live inside of the components directory.

matt

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs