# Selenium, Rails and rcov -- a solution and a question

**URL:** <https://www.ruby-forum.com/t/selenium-rails-and-rcov-a-solution-and-a-question/128202>\
**Category:** Rails\
**Created:** [February 5, 2008, 9:06pm UTC](https://www.ruby-forum.com/t/selenium-rails-and-rcov-a-solution-and-a-question/128202 "2008-02-05T21:06:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/df788c/32.png) [@kpd](https://www.ruby-forum.com/u/kpd)\
**Post date:** [February 5, 2008, 9:06pm UTC](https://www.ruby-forum.com/t/selenium-rails-and-rcov-a-solution-and-a-question/128202/1 "2008-02-05T21:06:46Z")

</div>

Hi there,

## We’ve been using rcov to generate coverage reports of our Selenium specs, which is really nifty. We use this rake task:

namespace :selenium do  
desc “Measure coverage of selenium specs”  
task :coverage do  
FileUtils.rm\_rf “selenium\_coverage”  
mongrel\_pid = fork { exec(“rcov script/server -o selenium\_coverage  
–rails – -e test -p 4000”) }  
sleep(6) # wait for mongrel to start

```
begin # selenium will call "exit 1" if there are failures
  Rake::Task["selenium:spec"].invoke
rescue SystemExit; end

Process.kill("INT", mongrel_pid) # triggers generation of rcov 

```

report  
Process.wait  
system(“open selenium\_coverage/index.html”) if PLATFORM[‘darwin’]  
end  
end

* * *

Unfortunately, the report does not include files that never get  
touched, which is bad. The only solution I’ve come up with is having  
Selenium hit a special controller action that requires all the files  
in the app. This works, but is obviously kludgy. Other solutions I  
tried all ran afoul of Rails’ load sequence. Anyone got bright ideas  
on this?

Krishna
