Skip to content

Commit 38524ce

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

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/rspec/rails/example/system_example_group.rb

Lines changed: 10 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,16 @@ def app
5963
""".gsub(/\s+/, ' ').strip
6064
end
6165

66+
original_before_teardown =
67+
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown)
68+
6269
original_after_teardown =
6370
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
6471

6572
other.include ActionDispatch::IntegrationTest::Behavior
6673
other.include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
6774
other.include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
68-
other.include BlowAwayAfterTeardownHook
75+
other.include BlowAwayTeardownHooks
6976

7077
attr_reader :driver
7178

@@ -93,6 +100,7 @@ def driven_by(*args, &blk)
93100
orig_stdout = $stdout
94101
$stdout = StringIO.new
95102
begin
103+
original_before_teardown.bind(self).call
96104
original_after_teardown.bind(self).call
97105
ensure
98106
myio = $stdout

0 commit comments

Comments
 (0)