Hi, I''ve installed coverage (gem install coverage) and try to run tests with -rcoverage option on, but following error occurs: ruby: No such file to load -- coverage (LoadError) I try: ruby -rcoverage mytest.rb 1. I have rubygems in evn var RUBYOPT 2. Gem seems to be installed properly (I can read doc via gems, the files exist in the ../gem/... dirs) Does anyone know what is the problem? Thanks in advance Szczepan _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Try Insurance instead, I''ve found it works pretty well. http://insurance.rubyforge.org/ - Jamie On Wed, 2005-12-28 at 22:15 +0100, Szczepan Faber wrote:> Hi, > > I''ve installed coverage (gem install coverage) and try to run tests > with -rcoverage option on, but following error occurs: > ruby: No such file to load -- coverage (LoadError) > > I try: > ruby -rcoverage mytest.rb > > 1. I have rubygems in evn var RUBYOPT > 2. Gem seems to be installed properly (I can read doc via gems, the > files exist in the ../gem/... dirs) > > Does anyone know what is the problem? > > Thanks in advance > Szczepan > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I had the same problem, and while I didn''t really figure out why it was happening, I figured out an easy workaround. For me, doing ''-rcoverage'' from the command line didn''t work, but if I put "require ''coverage''" into my app, that worked. But I didn''t WANT my app to require coverage, since then I''d get coverage all the time (or at least on every test, if I put it into test_helper.rb or someplace like that. To get around this conundrum, I made a file called test/enable_coverage.rb, which contains: require ''rubygems'' require ''coverage'' Then, from the command line, I can do something like: ruby -rtest/enable_coverage.rb test/unit/mytest.rb I don''t actually run it this way. Instead, I made a Rake task to do coverage, and I had the Rake task include that file, like this: desc "Run the unit, functional, and agent tests and generate coverage stats. You must have the coverage gem installed for this to work." Rake::TestTask.new(:test_coverage => [ :prepare_test_database ]) do |t| t.libs << "test" fl = FileList.new.include(''test/enable_coverage.rb'', ''test/unit/**/*_test.rb'', ''test/functional/**/*_test.rb'', ''test/agent/**/*_test.rb'') t.test_files = fl t.verbose = true end On 12/28/05, Szczepan Faber <szczepiq-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I''ve installed coverage (gem install coverage) and try to run tests with > -rcoverage option on, but following error occurs: > ruby: No such file to load -- coverage (LoadError) > > I try: > ruby -rcoverage mytest.rb > > 1. I have rubygems in evn var RUBYOPT > 2. Gem seems to be installed properly (I can read doc via gems, the files > exist in the ../gem/... dirs) > > Does anyone know what is the problem? > > Thanks in advance > Szczepan > > _______________________________________________ > 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
Insurance looks cool but I will wait for the next release of win32 ruby since Insurance requires 1.8.3 What about coverage? Michael, One enhancement I would make to your idea: My custom tasks file (placed in lib/tasks) looks: require ''coverage'' if ENV[''coverage'']==''true'' from command line I invoke standard rake builds (test_units, recent, etc.) but if I want coverage I insert ''coverage=true'', eg: rake test_units coverage=true Now I have almost the same development evironment as I would use -rcoverage. The problem is that in every new project I have to place my custom rake file (I don''t want to make dependencies in RUBY_HOME/lib/... /rails to coverage). I hate leaving some blank areas on the map behind. I think that gems in general do not work with ruby command line -r option (I tested it with some). Is it the problem with win2k I am using for development? Gems usage manual does not shed light on the matter (it states only about require ''xxx'' in the script. On the other hand in Pragmatic book about Rails the author is using coverage from command line -r option... Question: Can I use gem library just by including -rxxx in ruby command line (I have rubygems in RUBYOPT)? Thanks Szczepan 2005/12/29, Michael Smedberg <smedberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > I had the same problem, and while I didn''t really figure out why it was > happening, I figured out an easy workaround. > > For me, doing ''-rcoverage'' from the command line didn''t work, but if I put > "require ''coverage''" into my app, that worked. > > But I didn''t WANT my app to require coverage, since then I''d get coverage > all the time (or at least on every test, if I put it into test_helper.rb or > someplace like that. > > To get around this conundrum, I made a file called > test/enable_coverage.rb, which contains: > > require ''rubygems'' > require ''coverage'' > > Then, from the command line, I can do something like: > > ruby -rtest/enable_coverage.rb test/unit/mytest.rb > > I don''t actually run it this way. Instead, I made a Rake task to do > coverage, and I had the Rake task include that file, like this: > > > desc "Run the unit, functional, and agent tests and generate coverage > stats. You must have the coverage gem installed for this to work." > Rake::TestTask.new(:test_coverage => [ :prepare_test_database ]) do |t| > t.libs << "test" > fl = FileList.new.include(''test/enable_coverage.rb'', > ''test/unit/**/*_test.rb'', ''test/functional/**/*_test.rb'', > ''test/agent/**/*_test.rb'') > t.test_files = fl > t.verbose = true > end > > > On 12/28/05, Szczepan Faber <szczepiq-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > > I''ve installed coverage (gem install coverage) and try to run tests with > > -rcoverage option on, but following error occurs: > > ruby: No such file to load -- coverage (LoadError) > > > > I try: > > ruby -rcoverage mytest.rb > > > > 1. I have rubygems in evn var RUBYOPT > > 2. Gem seems to be installed properly (I can read doc via gems, the > > files exist in the ../gem/... dirs) > > > > Does anyone know what is the problem? > > > > Thanks in advance > > Szczepan > > > > _______________________________________________ > > 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 > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 12/29/05, Szczepan Faber <szczepiq@gmail.com> wrote:> Michael, > One enhancement I would make to your idea: > > My custom tasks file (placed in lib/tasks) looks: > require ''coverage'' if ENV[''coverage'']==''true'' > > from command line I invoke standard rake builds (test_units, recent, etc.) > but if I want coverage I insert ''coverage=true'', eg: > > rake test_units coverage=trueI made a file lib/tasks/default.rake with only "require ''coverage'' if ENV[''coverage'']==''true''", but when I run "rake coverage=true" only index.html, environment.rb.html, routes.rb.html, and boot.rb.html are generated. The quality of those results isn''t very good anyway. It counts continuation lines as not being covered and stopped midway through my environment.rb for some reason. Is it working better than this on your system?> Thanks > SzczepanSincerely, Tom Lieber http://AllTom.com/ http://GadgetLife.org/
Hi Move following line: require ''coverage'' if ENV["coverage"] == ''true'' to top of your test_helper.rb :) 2006/1/8, Tom Lieber <alltom@gmail.com>:> > On 12/29/05, Szczepan Faber <szczepiq@gmail.com> wrote: > > Michael, > > One enhancement I would make to your idea: > > > > My custom tasks file (placed in lib/tasks) looks: > > require ''coverage'' if ENV[''coverage'']==''true'' > > > > from command line I invoke standard rake builds (test_units, recent, > etc.) > > but if I want coverage I insert ''coverage=true'', eg: > > > > rake test_units coverage=true > > I made a file lib/tasks/default.rake with only "require ''coverage'' if > ENV[''coverage'']==''true''", but when I run "rake coverage=true" only > index.html, environment.rb.html, routes.rb.html, and boot.rb.html are > generated. The quality of those results isn''t very good anyway. It > counts continuation lines as not being covered and stopped midway > through my environment.rb for some reason. > > Is it working better than this on your system? > > > Thanks > > Szczepan > > Sincerely, > > Tom Lieber > http://AllTom.com/ > http://GadgetLife.org/ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060108/3ed6ec2a/attachment.html
For me works cool. I mean it highlights covered code in all tested files. Coverage is too slow :( and eventually I move to Insurance, though Thanks, Szczepan 2006/1/8, Tom Lieber <alltom@gmail.com>:> > On 1/8/06, Tom Lieber <alltom@gmail.com> wrote: > > More happens, but it doesn''t seem to detect any of _my_ code; all I > > get is results for *_test.rb and helpers, and it says that none of the > > test code was actually run (none of the method bodies are highlighted > > in the results for the *_test.rb files). > > Despite this, Insurance works like a charm. Excellent. > > > Sincerely, > > > > Tom Lieber > > http://AllTom.com/ > > http://GadgetLife.org/ > > Sincerely, > > Tom Lieber > http://AllTom.com/ > http://GadgetLife.org/ >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060108/9c5ebf86/attachment-0001.html