创建包含以下内容的测试的最佳方式是什么:
- 设置复选框
- 灌木丛按钮
- 等等
用于 Ruby on Rails 测试环境?
最佳答案
使用 ActionDispatch::IntegrationTest
来做到这一点。
有关更多信息,请参阅指南:http://guides.rubyonrails.org/testing.html#integration-testing
如果你想要更好的 html 控件,你可以使用 capybara为了这。 (请参阅 repo 协议(protocol)的自述文件)
在您的情况下,测试看起来像这样(使用 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
关于ruby-on-rails - 如何为 Ruby on Rails 创建功能测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39206374/