I am trying to run some functional (or are they unit?) tests on my
application_helper.rb. So far, I''ve not had any success in being able
to call the methods defined in application_helper.rb.
Here is my app/test/functional/helpers.rb
require File.dirname(__FILE__) + ''/../test_helper''
require File.dirname(__FILE__) +
''/../../app/helpers/application_helper''
class HelpersTest < Test::Unit::TestCase
def setup
end
def test_foo
result = foo( "test parameter 1" )
assert_equal true, result
end
end
However, I get method not found errors (it can''t find foo()) when
trying to run the test. What am I doing wrong?
Similarly, how does one go about functional testing application.rb?
Thanks.
Matt
On Jul 22, 2005, at 10:03 AM, Belorion wrote:> I am trying to run some functional (or are they unit?) tests on my > application_helper.rb. So far, I''ve not had any success in being able > to call the methods defined in application_helper.rb. > > Here is my app/test/functional/helpers.rb > > require File.dirname(__FILE__) + ''/../test_helper''# shouldn''t need this line> require File.dirname(__FILE__) + > ''/../../app/helpers/application_helper'' > > class HelpersTest < Test::Unit::TestCase# You may need to pull in some other helpers, depending on what # your helpers depend on, like this: # include ActionView::Helpers::TextHelper # Pull in your helper(s) include ApplicationHelper> def setup > end > > def test_foo > result = foo( "test parameter 1" ) > assert_equal true, result > end > > end-Scott
Matt, define a new class which includes the helber module and use
this class within your test:
require File.dirname(__FILE__) + ''/../test_helper''
class ApplicationHelperTest < Test::Unit::TestCase
class MyApplicationHelper
include ApplicationHelper
end
def setup
@ah = MyApplicationHelper.new
end
def test_truth
assert_equal 4, @ah.foo
end
end
Am 22.07.2005 um 16:03 schrieb Belorion:
> I am trying to run some functional (or are they unit?) tests on my
> application_helper.rb. So far, I''ve not had any success in being
able
> to call the methods defined in application_helper.rb.
>
> Here is my app/test/functional/helpers.rb
>
> require File.dirname(__FILE__) + ''/../test_helper''
> require File.dirname(__FILE__) + ''/../../app/helpers/
> application_helper''
>
> class HelpersTest < Test::Unit::TestCase
> def setup
> end
>
> def test_foo
> result = foo( "test parameter 1" )
> assert_equal true, result
> end
>
> end
>
> However, I get method not found errors (it can''t find foo()) when
> trying to run the test. What am I doing wrong?
>
> Similarly, how does one go about functional testing application.rb?
>
> Thanks.
>
> Matt
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Ralf Wirdemann - Freiberuflicher Softwarecoach
ralf.wirdemann-95+UFKxf6Ncb1SvskN2V4Q@public.gmane.org
Begel 20a
22359 Hamburg
mobil: +49(174)183 6410 fax: +49(40)411 622 36
I figured it out. I feel silly now. I had simply left out the include statements: require File.dirname(__FILE__) + ''/../test_helper'' require File.dirname(__FILE__) + ''/../../app/helpers/application_helper'' require "erb" include ERB::Util include ApplicationHelper