私は現在、AJAX(jQuery)を介してページに読み込まれる課金フォームの機能テストを作成しようとしています。これは、consult_form.js.erbビューを返すcharge_formアクションからフォームをロードします。
これはすべて機能しますが、テストに問題があります。
ファンクションでは、アクションに移動できますが、assert_selectを使用して要素を検索し、フォームが実際にそこにあることを確認することはできません。
エラー:
1) Failure:
test_should_create_new_consult(ConsultsControllerTest) [/test/functional/consults_controller_test.rb:8]:
Expected at least 1 element matching "h4", found 0.
<false> is not true.
これがビューです。Consult_form.js.erb:
<div id="charging_form">
<h4>Charging form</h4>
<div class="left" id="charge_selection">
<%= select_tag("select_category", options_from_collection_for_select(@categories, :id, :name)) %><br/>
...
Consults_controller_test.rb:
require 'test_helper'
class ConsultsControllerTest < ActionController::TestCase
def test_should_create_new_consult
get_with_user :charge_form, :animal_id => animals(:one), :id => consults(:one), :format => 'js'
assert_response :success
assert_select 'h4', "Charging form" #can't find h4
end
end
html以外のタイプでassert_selectを使用することに問題はありますか?
助けてくれてありがとう!