I am (still, apparently, learning) trying to run a test on a helper but I get this: ----> 1) Failure: test_collection_table_initialize(CollectionTableHelperTest) [collection_table_helper_test.rb:16]: Exception raised: Class: <NameError> Message: <"uninitialized constant CollectionTableHelper"> ---Backtrace--- /var/lib/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:183:in `const_missing'' collection_table_helper_test.rb:17:in `test_collection_table_initialize'' collection_table_helper_test.rb:16:in `assert_nothing_raised'' collection_table_helper_test.rb:16:in `test_collection_table_initialize'' -----< for test/unit/collection_table_helper_test.rb: -----> require File.dirname(__FILE__) + ''/../test_helper'' require ''rubygems'' require ''collection_table_helper'' class CollectionTableHelperTest < Test::Unit::TestCase TestItem = Struct.new(:id, :name, :phone) TestItemB = Struct.new(:id, :phone) def setup @xml = Builder::XmlMarkup.new @items = [ TestItem.new(1, ''John Doe'', ''555-5555''), TestItem.new(2, ''Jane Doe'', ''666-6666'') ] end def test_collection_table_initialize assert_nothing_raised do ct = CollectionTableHelper::CollectionTable.new(@xml, @items, :id, :name, :phone) end end end -----< app/helpers/collection_table_helper.rb: CollectionTableHelper::CollectionTable::initialize is: -----> def initialize(xml, items, *columns) @xml = xml [...all old stuff...] end -----< How can this be? What should I look for? Arrrrrrg! Thanks! Russell
I''m still stuck trying to test a helper, is there anything I need to do beyond simply putting in the simplest possible case: app/helpers/rlc_helper.rb: module RlcHelper class Rlc def initialize end end and test/unit/rlc_helper_test.rb: #!/usr/bin/ruby require File.dirname(__FILE__) + ''/../test_helper'' require ''rlc_helper'' class RlcHelperTest < Test::Unit::TestCase def setup end def test_rlc_table_initialize assert_nothing_raised do ct = RlcHelper::Rlc.new end end end The "require ''rlc_helper''" statement succeeds, why do I get this: Exception raised: Class: <NameError> Message: <"uninitialized constant RlcHelper"> Thanks, Russell Russell L. Carter wrote:>I am (still, apparently, learning) trying to run a test on a helper but >I get this: > >----> > 1) Failure: >test_collection_table_initialize(CollectionTableHelperTest) >[collection_table_helper_test.rb:16]: >Exception raised: >Class: <NameError> >Message: <"uninitialized constant CollectionTableHelper"> >---Backtrace--- >/var/lib/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:183:in >`const_missing'' >collection_table_helper_test.rb:17:in `test_collection_table_initialize'' >collection_table_helper_test.rb:16:in `assert_nothing_raised'' >collection_table_helper_test.rb:16:in `test_collection_table_initialize'' >-----< > >for test/unit/collection_table_helper_test.rb: > >-----> >require File.dirname(__FILE__) + ''/../test_helper'' >require ''rubygems'' >require ''collection_table_helper'' > >class CollectionTableHelperTest < Test::Unit::TestCase > TestItem = Struct.new(:id, :name, :phone) > TestItemB = Struct.new(:id, :phone) > > def setup > @xml = Builder::XmlMarkup.new > @items = [ TestItem.new(1, ''John Doe'', ''555-5555''), > TestItem.new(2, ''Jane Doe'', ''666-6666'') ] > end > > def test_collection_table_initialize > assert_nothing_raised do > ct = CollectionTableHelper::CollectionTable.new(@xml, @items, :id, >:name, :phone) > end > end >end >-----< > >app/helpers/collection_table_helper.rb: >CollectionTableHelper::CollectionTable::initialize is: > >-----> >def initialize(xml, items, *columns) > @xml = xml > [...all old stuff...] >end >-----< > >How can this be? What should I look for? Arrrrrrg! > >Thanks! >Russell >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >
Well, now I know that all this stuff: Exception raised: Class: <NameError> Message: <"uninitialized constant CollectionTableHelper"> ---Backtrace--- /var/lib/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:183:in `const_missing'' ./collection_table_helper_test.rb:19:in `test_collection_table_initialize'' ./collection_table_helper_test.rb:18:in `assert_nothing_raised'' ./collection_table_helper_test.rb:18:in `test_collection_table_initialize'' --------------- is actually a precise synonym for ''syntax error'', although without a useful line number. Good to clear that up. Recorded here for other noobs. Russell Russell L. Carter wrote:>I''m still stuck trying to test a helper, is there anything >I need to do beyond simply putting in the simplest possible >case: > >app/helpers/rlc_helper.rb: > >module RlcHelper > class Rlc > def initialize > end >end > >and test/unit/rlc_helper_test.rb: > >#!/usr/bin/ruby >require File.dirname(__FILE__) + ''/../test_helper'' >require ''rlc_helper'' >class RlcHelperTest < Test::Unit::TestCase > def setup > end > def test_rlc_table_initialize > assert_nothing_raised do > ct = RlcHelper::Rlc.new > end > end >end > >The "require ''rlc_helper''" statement succeeds, why do I get this: > >Exception raised: >Class: <NameError> >Message: <"uninitialized constant RlcHelper"> > >Thanks, >Russell > >Russell L. Carter wrote: > > > >>I am (still, apparently, learning) trying to run a test on a helper but >>I get this: >> >>----> >> 1) Failure: >>test_collection_table_initialize(CollectionTableHelperTest) >>[collection_table_helper_test.rb:16]: >>Exception raised: >>Class: <NameError> >>Message: <"uninitialized constant CollectionTableHelper"> >>---Backtrace--- >>/var/lib/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:183:in >>`const_missing'' >>collection_table_helper_test.rb:17:in `test_collection_table_initialize'' >>collection_table_helper_test.rb:16:in `assert_nothing_raised'' >>collection_table_helper_test.rb:16:in `test_collection_table_initialize'' >>-----< >> >>for test/unit/collection_table_helper_test.rb: >> >>-----> >>require File.dirname(__FILE__) + ''/../test_helper'' >>require ''rubygems'' >>require ''collection_table_helper'' >> >>class CollectionTableHelperTest < Test::Unit::TestCase >> TestItem = Struct.new(:id, :name, :phone) >> TestItemB = Struct.new(:id, :phone) >> >> def setup >> @xml = Builder::XmlMarkup.new >> @items = [ TestItem.new(1, ''John Doe'', ''555-5555''), >> TestItem.new(2, ''Jane Doe'', ''666-6666'') ] >> end >> >> def test_collection_table_initialize >> assert_nothing_raised do >> ct = CollectionTableHelper::CollectionTable.new(@xml, @items, :id, >>:name, :phone) >> end >> end >>end >>-----< >> >>app/helpers/collection_table_helper.rb: >>CollectionTableHelper::CollectionTable::initialize is: >> >>-----> >>def initialize(xml, items, *columns) >> @xml = xml >> [...all old stuff...] >>end >>-----< >> >>How can this be? What should I look for? Arrrrrrg! >> >>Thanks! >>Russell >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> >> > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >