我有这样我的测试代码有什么问题?
find("div#cycle_form table").should have_content(append_row_to_table_tag("day_num", "hour", "hour_night"))
方法步骤定义黄瓜append_row_to_table_tag返回字符串
"<tr><td>data</td><td>data</td><td>data</td><td>data</td><td>data</td></tr>"
和视图
%div{:id => "cycle_form", :class=>"list_form"}
= link_to("Add",nil,:id=>"create_row_cycle")#,:onclick=>"$('div#cycle_form table').append('#{append_row_to_table_tag("day_num", "hour", "hour_night")}');return false;", :href=>"")
%table
%th day
%th hour
%th hour_night
%th edit_button
%th delete_button
黄瓜失败
expected there to be content "<tr><td>data</td><td>data</td><td>data</td><td>data</td>
<td>data</td></tr>" in "day hour hour_night edit_button delete_button\ndata data data
data data" (RSpec::Expectations::ExpectationNotMetError)
如何使用水豚在JavaScript中添加元素?
感谢您的重播,Skydreamer!我与水豚学了黄瓜..怎么可以与水豚一起测试? (“div#cycle_form table”)。text.should have_content(append_row_to_table_tag(“day_num”,“hour”,“hour_night”))为什么我收到此通知“预计会有内容” – dilshod 2012-02-04 15:06:12
问题已解决 find – dilshod 2012-02-04 17:00:00