Skip to content

Commit

Permalink
Blowaway before hooks as well as after hooks to preserve order
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Aug 23, 2019
1 parent 9c6d8f3 commit 38524ce
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/rspec/rails/example/system_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ module SystemExampleGroup
CHARS_TO_TRANSLATE = ['/', '.', ':', ',', "'", '"', " "].freeze

# @private
module BlowAwayAfterTeardownHook
module BlowAwayTeardownHooks
# @private
def before_teardown
end

# @private
def after_teardown
end
Expand Down Expand Up @@ -59,13 +63,16 @@ def app
""".gsub(/\s+/, ' ').strip
end

original_before_teardown =
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown)

original_after_teardown =
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)

other.include ActionDispatch::IntegrationTest::Behavior
other.include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
other.include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
other.include BlowAwayAfterTeardownHook
other.include BlowAwayTeardownHooks

attr_reader :driver

Expand Down Expand Up @@ -93,6 +100,7 @@ def driven_by(*args, &blk)
orig_stdout = $stdout
$stdout = StringIO.new
begin
original_before_teardown.bind(self).call
original_after_teardown.bind(self).call
ensure
myio = $stdout
Expand Down

0 comments on commit 38524ce

Please sign in to comment.