테스트AJAX 호출을 통해 추가 된 내용을 확인하기 위해 기능/컨트롤러 테스트를 어떻게 작성합니까?
def test_generateCashFlowStmt
get :getDateRangeForCashFlowStmt
xhr :post,
:generate_cash_flow_stmt,
{:fromDate => {:year=>"2009", :month => "3", :day=>"1"},
:toDate => {:year=>"2009", :month => "3", :day=>"31"} }
table = [ .... ]
assert_equal table, formatCashFlowStatementAsTable(assigns(:cashFlowStmt))
assert_tag :tag => "div", :children => {:count => 1, :only => {:tag=>"table"} }
end
컨트롤러 조치
def generate_cash_flow_stmt
puts params
fromDate = Date.civil params[:fromDate]["year"].to_i, params[:fromDate]["month"].to_i, params[:fromDate]["day"].to_i
toDate = Date.civil params[:toDate]["year"].to_i, params[:toDate]["month"].to_i, params[:toDate]["day"].to_i
@cashFlowStmt = CashFlowStatement.new(fromDate, toDate)
render :partial => "cash_flow_stmt", :layout => false
end
보기
<% form_remote_tag(:loading => "Element.show('progress-indicator');",
:update => "div_results",
:complete => "Element.hide('progress-indicator');",
:url=>{:action=>'generate_cash_flow_stmt'}) do %>
...
<% end %>
<div id="div_results">
테스트는 DIV 콘텐츠 홀더가 채워집니다 만약 내가 확인 마지막 검사에서 실패 generate_cash_flow_stmt ac의 호출의 결과로서의 테이블 운. 테이블이 브라우저에 표시되는 것을 볼 수 있지만 '소스보기'작업에 빈 div 태그가 표시됩니다. 뭐라 구요?