#262 open
Kurt Kowar

webrat in selenium mode reports files executed in rcov but doesn't reflect the code that was executed

Reported by Kurt Kowar | June 9th, 2009 @ 06:56 PM

Comments and changes to this ticket

  • gaffo

    gaffo June 10th, 2009 @ 03:39 PM

    • State changed from “new” to “open”

    Kurt, I'm not really sure what you mean by this.

  • Edgars Beigarts

    Edgars Beigarts July 8th, 2009 @ 09:15 AM

    Selenium starts mongrel in backround so coverage is not calculated for this processs.

    I have moneky patched RailsApplicationServer start_command and now it displays correctly for me.

    It wotk un mac and linux. On windows i don't know how to get path to mongrel_rails (on linux i can get it with whitch command) ?

    @@@ require "webrat/selenium/rails_application_server"

    module Webrat
    module Selenium

    class RailsApplicationServer < ApplicationServer
      def start_command_with_rcov
        rcov_opts = %{--exclude "spec/*,gems/*,features/*,/Library/*" --rails --aggregate "coverage.data"}
        mongrel_rails_path = `which mongrel_rails`.delete("\n")
        start_command = start_command_without_rcov.gsub("mongrel_rails", "#{mongrel_rails_path} --")
        "rcov #{rcov_opts} #{start_command}"
      end
      alias_method_chain :start_command, :rcov
    end
    

    end end

    
    @@@ rcov --exclude "spec/,gems/,features/,/Library/" --rails --aggregate "coverage.data" /usr/bin/mongrel_rails -- start -d --chdir='/Users/be/code/mycrm' --port=3000 --environment=test --pid ~/code/test_app/tmp/pids/mongrel_selenium.pid &
    
  • gaffo

    gaffo July 8th, 2009 @ 09:59 AM

    Edgars,

    You may want to take a look at:
    

    http://github.com/gaffo/mainline, it might be doing what you want.

    -Mike

  • Jonathan Hicks

    Jonathan Hicks July 14th, 2009 @ 06:17 PM

    Mike,

    I tried using Mainline with cucumber+webrat+selenium and the Readme example didn't work. It seems like Mainline is what is needed to pull in the coverage data gathered from selenium but why shouldn't this be part of webrat?

  • Julio Avero

    Julio Avero April 9th, 2010 @ 02:49 PM

    I had a similar problem in one of my projects (Rcov not working along with Webrat), however I was able to work it round using Edgards idea with some small changes:

    require "webrat/selenium/application_servers/rails"
    module Webrat
    module Selenium

    module ApplicationServers
      class Rails < Webrat::Selenium::ApplicationServers::Base
        def start_command_with_rcov
          rcov_opts = %{--exclude "spec/*,gems/*,features/*,/Library/*" --rails --aggregate "coverage.data"}
          mongrel_rails_path = `which mongrel_rails`.delete("\n")
          start_command = start_command_without_rcov.gsub("mongrel_rails", "#{mongrel_rails_path} --")
          "rcov #{rcov_opts} #{start_command}"
        end
        alias_method_chain :start_command, :rcov     
      end
    end
    

    end end

    His patch does not work the way it is anymore, due to some refactoring in Webrat.

    Hope it helps, cheers!

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Pages