ChaosPredictor ChaosPredictor - 1 month ago 4x
Ruby Question

How to create functional test for Ruby on Rails

What is the best way create tests that include:

  • set checkbox

  • bush buttom

  • etc.

for Ruby on Rails test environment?


Use ActionDispatch::IntegrationTest to do this.

See the guides for more information:

If you want a better html control you can use capybara for this. (see the repo's README)

In your case the test would look something like this (with 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.

Make sure that you have it setup right! See: