创建包含以下内容的测试的最佳方法是什么:
用于Ruby on Rails测试环境?
答案 0 :(得分:1)
使用ActionDispatch::IntegrationTest
执行此操作。
有关详细信息,请参阅指南:http://guides.rubyonrails.org/testing.html#integration-testing
如果您想要更好的html控件,可以使用capybara。 (参见回购自述文件)
在你的情况下,测试看起来像这样(与水豚):
class UiTest < ActionDispatch::IntegrationTest
test "select check box and push button" do
visit "/my-route"
check "A Checkbox" # => you can use the label or the id here
click_on "A button" # => here too.
end
end
确保安装正确!请参阅:https://github.com/jnicklas/capybara#using-capybara-with-testunit