Skip to content

Commit 377d1e8

Browse files
committed
[#75] Fix a timing bug with poltergeist/turbolinks
There's a timing bug in ViewHelperTest that randomly results in ```ReferenceError: Turbolinks Not Found```. This causes unrelated builds to fail, which gums up the whole open source works. Per https://github.com/teampoltergeist/poltergeist#timing-problems, the suggested way of fixing this is to just add calls to sleep. If you wish to test this in the future, use the shell code: ```for i in `seq 1 10`; do rake appraisal; done``` This should give you enough test runs to hit the timing bug at least once.
1 parent b6d3294 commit 377d1e8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

test/test_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@
2222
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
2323
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
2424
end
25+
26+
def wait_for_turbolinks_to_be_available
27+
sleep(1)
28+
end

test/view_helper_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ class ViewHelperTest < ActionDispatch::IntegrationTest
6262
page.execute_script('history.back();')
6363
assert page.has_content?('Hello Alice')
6464

65+
wait_for_turbolinks_to_be_available()
66+
6567
# Try Turbolinks javascript API.
6668
page.execute_script('Turbolinks.visit("/pages/2");')
6769
assert page.has_content?('Hello Alice')
6870

71+
wait_for_turbolinks_to_be_available()
72+
6973
page.execute_script('Turbolinks.visit("/pages/1");')
7074
assert page.has_content?('Hello Bob')
7175

0 commit comments

Comments
 (0)