tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-04 19:12 UTC
Testing library code
Hi, Just a quick question: If one creates custom classes and modules and places them in the lib/ folder of rails, where should the tests for those classes/modules go? Are they just unit tests? Thanks, Toby --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Hi, > > Just a quick question: If one creates custom classes and modules and > places them in the lib/ folder of rails, where should the tests for > those classes/modules go? Are they just unit tests? > > Thanks, > TobyWell it is just ruby code so you can make a small ruby application and test it that way, and you can do it with test too I presume. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-04 21:41 UTC
Re: Testing library code
What I mean is that I would like to use test::unit to test my modules and classes but I''m not sure where to put the test I write in the directory structure of rails. Some of my controllers rely on these modules/classes so they require testing, I''m just not sure how to go about it. On Aug 4, 9:20 pm, Scott Pn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> tobyclem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > Hi, > > > Just a quick question: If one creates custom classes and modules and > > places them in the lib/ folder of rails, where should the tests for > > those classes/modules go? Are they just unit tests? > > > Thanks, > > Toby > > Well it is just ruby code so you can make a small ruby application and > test it that way, and you can do it with test too I presume. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I tend to think of them as part of my unit tests
(that is the way they generally get used)
If you want to put in a bit of work, you could very easily add a
/test/lib directory
and define a "test:libs" rake command.
namespace :test do
Rake::TestTask.new(:libs => "db:test:prepare") do |t|
t.libs << "test"
t.pattern = ''test/lib/**/*_test.rb''
t.verbose = true
end
Rake::Task[''test:libs''].comment = "Run the lib tests
in test/lib"
end
stick that in a file in lib/tasks
you''d then want to overwrite the default test task, like so...
desc ''Test all units and functionals''
task :test do
exceptions = ["test:units", "test:libs",
"test:functionals",
"test:integration"].collect do |task|
begin
Rake::Task[task].invoke
nil
rescue => e
e
end
end.compact
exceptions.each {|e| puts e;puts e.backtrace }
raise "Test failures" unless exceptions.empty?
end
(note: all of the code above is made from just small changes to the
default tasks, found inside the rails gem --
/rails/lib/tasks/testing.rake
tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
wrote:> What I mean is that I would like to use test::unit to test my modules
> and classes but I''m not sure where to put the test I write in the
> directory structure of rails. Some of my controllers rely on these
> modules/classes so they require testing, I''m just not sure how to
go
> about it.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> What I mean is that I would like to use test::unit to test my modules > and classes but I''m not sure where to put the test I write in the > directory structure of rails. Some of my controllers rely on these > modules/classes so they require testing, I''m just not sure how to go > about it.Put all unit-level tests in test/unit. The meaning of "unit test" isn''t "model test"; it''s generally the low-level tests. If you don''t want to run too many tests between each edit, google for "test:svn_modified" and use that to trigger only the tests files you changed since your last integration. -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---