There are a lot of examples on how to perform javascript tests with Capybara/Selenium/Rspec in which you can write a test like so:
it \"does som
What :js
flag is doing is very simple. It switches the current driver from default (rack-test) to another one that supports javascript execution (selenium, webkit). You can do the same thing in minitest:
require "minitest/autorun"
class WebsiteTest < MiniTest::Unit::TestCase
def teardown
super
Capybara.use_default_driver
end
def test_with_javascript
Capybara.current_driver = :selenium
visit "/"
click_link "Hide"
assert has_no_link?("Hide")
end
def test_without_javascript
visit "/"
click_link "Hide"
assert has_link?("Hide")
end
end
Of course you can abstract this into a module for convenience:
require "minitest/autorun"
module PossibleJSDriver
def require_js
Capybara.current_driver = :selenium
end
def teardown
super
Capybara.use_default_driver
end
end
class MiniTest::Unit::TestCase
include PossibleJSDriver
end
class WebsiteTest < MiniTest::Unit::TestCase
def test_with_javascript
require_js
visit "/"
click_link "Hide"
assert has_no_link?("Hide")
end
def test_without_javascript
visit "/"
click_link "Hide"
assert has_link?("Hide")
end
end