在我的应用程序内我使用了一个jQuery插件FullCalendar - 它是一个看起来像Google日历的jQuery日历。功能测试,jQuery和assert_select_jquery
我想写测试日历正在显示(CalendarController#索引)的功能测试(CalendarControllerTest < ActionController :: TestCase)。
这将是容易,如果日历是普通的HTML,而是用JavaScript编写所以在我的HTML页面我有:
<script src="fullcalendar.js" type="text/javascript"></script>
<script src="calendar.js" type="text/javascript"></script>
[...]
<div id="calendar"></div>
内calendar.js(脚手架从Rails的3.1 - CalendarController + calendar.js + calendar.css + CalendarControllerTest)我加载FullCalendar:
$('#calendar').fullCalendar();
因此我的功能测试内侧(CalendarControllerTest)此将不起作用:
# Checks <div class="fc-content"> is present i.e the calendar is being displayed
assert_select '.fc-content', count: 1
我试图用assert_select_jquery没有成功:
assert_select_jquery :html, '#calendar' do
assert_select '.fc-content', count: 1
end
我知道Webrat /水豚但是从我看到它是用于集成测试不起作用试验。
你会怎么做?