Search code examples
ruby-on-railsruby-on-rails-4

How to refresh(reload) current url in Rails Minitest?


I am writing a test using Minitest in rails, i need to refresh the page(url) without get request so that i can see ajax changes made on page

  test "z" do
    assert_select "my_div", 0
    ajax_activity()
    #here i want to refresh the page
    # right now i am using get "/dashboard"
    #which is working fine
    get "/dashboard"
    assert_select "my_div", "1"
  end

Solution

  • You'll need to use capybara and some headless browser driver (e.g. selenium) to be able to test ajax activity (or javascript in general) on your pages. Be sure to read the README chapter dealing with AJAX requests and timeouts too.

    Some introductory guidance can be taken from this railscast (though it uses RSpec instead of Minitest), there is a plenty of more concrete information on the web, try googling for something like this. Be sure to read the capybara README chapter dealing with AJAX requests and timeouts too.