これが私のコントローラーです:
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
...ベースとなるヘルパー:
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
...そして私の機能テスト(Shouldaを使用しています):
class MyControllerTest < ActionController::TestCase
context "MyController index" do
setup do
get :index
end
should_respond_with :success
end
end
EDIT私のrcovレーキは、公式のFAQにリストされているものとまったく同じです:eigenclass.org
RCov (0.9.7.1) は、コントローラー内の「def index」までのすべての行を緑としてリストし、それ以降のすべての行 (すべての「終了」を含む) を赤/未実行としてリストします。テストを実際に実行すると、コードが正常に実行されることがわかっています。
RCov が直観的ではない結果をもたらすのはなぜですか? 私がここに欠けているものはありますか?