如何为Ruby on Rails创建功能测试

时间:2016-08-29 12:28:16

标签: ruby-on-rails ruby testing

创建包含以下内容的测试的最佳方法是什么:

  • 设置复选框
  • bush buttom

用于Ruby on Rails测试环境?

1 个答案:

答案 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

相关问题