With RSpec and Capybara, I used to write the following code to test for features in pages that had some javascript going on:
feature "Some Feature" do
scenario "testing some scenario", js: true do
# code
end
end
Now, using Test::Unit with Capybara, how do I achieve the same result? 'Cause when I do test 'checks some feature on some scenario', js: true
it doesn't seem to work.
EDIT
So, I was able to workaround with the following:
setup do
Capybara.current_driver = Capybara.javascript_driver
end
teardown do
Capybara.current_driver = Capybara.default_driver
end
test 'checks some feature on some scenario with javascript goin on' do
# code
end
Is there any other solution without such a boilerplate code?
Ok, I end up resolving that by defining a method in test_helper.rb
that wraps the test within the capybara driver assigning:
def js
Capybara.current_driver = Capybara.javascript_driver
yield
Capybara.current_driver = Capybara.default_driver
end
And using it like:
test 'checks some feature on some scenario with javascript goin on' do
js do
# code
end
end
I read that minitest-data could be of use here, but I didn't dig out any further.