Here's my controller:
class MyController < ApplicationController
include MyHelper
def index
get_list_from_params do |list|
@list = list
respond_to do |format|
format.html
format.xml { render :xml => @list }
format.json { render :json => @list }
end
end
end
end
...the helper that it's based on:
module MyHelper
def get_list_from_params(param = :id, &on_success)
raw_id = params[param]
begin
id = Integer(raw_id)
rescue
render :template => "invalid_id", :locals => {:id => raw_id }
else
yield MyList.new(id)
end
end
end
...and my functional test (which is using Shoulda):
class MyControllerTest < ActionController::TestCase
context "MyController index" do
setup do
get :index
end
should_respond_with :success
end
end
EDIT My rcov rake is exactly the same as the one listed in the official FAQ: eigenclass.org
RCov (0.9.7.1) lists every line in the controller up to "def index" as green, and every line after that (including all of the "end"s) as red/unexecuted. I know that when my test actually executes, it does execute the code successfully.
Why does RCov give unintuitive results? Is there something I'm missing here?