Skip to content

Commit f01e4ff

Browse files
committed
Blowaway before hooks as well as after hooks to preserve order
1 parent 9c6d8f3 commit f01e4ff

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/rspec/rails/example/system_example_group.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ module SystemExampleGroup
1515
CHARS_TO_TRANSLATE = ['/', '.', ':', ',', "'", '"', " "].freeze
1616

1717
# @private
18-
module BlowAwayAfterTeardownHook
18+
module BlowAwayTeardownHooks
19+
# @private
20+
def before_teardown
21+
end
22+
1923
# @private
2024
def after_teardown
2125
end
@@ -59,13 +63,18 @@ def app
5963
""".gsub(/\s+/, ' ').strip
6064
end
6165

66+
if ::Rails::VERSION::STRING >= '6.0'
67+
original_before_teardown =
68+
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown)
69+
end
70+
6271
original_after_teardown =
6372
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
6473

6574
other.include ActionDispatch::IntegrationTest::Behavior
6675
other.include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
6776
other.include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
68-
other.include BlowAwayAfterTeardownHook
77+
other.include BlowAwayTeardownHooks
6978

7079
attr_reader :driver
7180

@@ -93,6 +102,9 @@ def driven_by(*args, &blk)
93102
orig_stdout = $stdout
94103
$stdout = StringIO.new
95104
begin
105+
if ::Rails::VERSION::STRING >= '6.0'
106+
original_before_teardown.bind(self).call
107+
end
96108
original_after_teardown.bind(self).call
97109
ensure
98110
myio = $stdout

0 commit comments

Comments
 (0)