Skip to content

Commit 57a4bbc

Browse files
author
Sam Phippen
committed
Revert "Refactor system test implementation to be good"
This reverts commit 53d3225.
1 parent 7634998 commit 57a4bbc

File tree

1 file changed

+37
-16
lines changed

1 file changed

+37
-16
lines changed

lib/rspec/rails/example/system_example_group.rb

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,47 @@ module Rails
55
# @api public
66
# Container class for request spec functionality.
77
module SystemExampleGroup
8-
# In rails system test inherits from integration test.
9-
# RequestExampleGroup wraps that, so we just include it here
10-
include RSpec::Rails::RequestExampleGroup
8+
extend ActiveSupport::Concern
9+
include RSpec::Rails::RailsExampleGroup
10+
include ActionDispatch::Integration::Runner
11+
include ActionDispatch::Assertions
12+
include RSpec::Rails::Matchers::RedirectTo
13+
include RSpec::Rails::Matchers::RenderTemplate
14+
include ActionController::TemplateAssertions
1115

12-
original_after_teardown = ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
13-
14-
module SystemTestHooks
15-
include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
16-
include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
17-
# for the SystemTesting Screenshot situation
18-
def passed?
19-
RSpec.current_example.exception.nil?
20-
end
16+
include ActionDispatch::IntegrationTest::Behavior
2117

18+
module BlowAwayAfterTeardownHook
2219
def after_teardown
2320
end
2421
end
25-
include SystemTestHooks
2622

27-
included do
28-
attr_reader :driver
23+
original_after_teardown = ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
24+
25+
include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
26+
include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
27+
include BlowAwayAfterTeardownHook
28+
29+
# for the SystemTesting Screenshot situation
30+
def passed?
31+
RSpec.current_example.exception.nil?
32+
end
2933

34+
35+
# Delegates to `Rails.application`.
36+
def app
37+
::Rails.application
38+
end
39+
40+
included do
3041
def driven_by(*args, &blk)
31-
@driver = ::ActionDispatch::SystemTestCase.driven_by(*args, &blk).tap(&:use)
42+
@driver = ::ActionDispatch::SystemTestCase.driven_by(*args, &blk).tap { |d|
43+
d.use
44+
}
45+
end
46+
47+
def driver
48+
@driver
3249
end
3350

3451
before do
@@ -39,6 +56,10 @@ def driven_by(*args, &blk)
3956
after do
4057
original_after_teardown.bind(self).call
4158
end
59+
60+
around do |ex|
61+
ex.run
62+
end
4263
end
4364
end
4465
end

0 commit comments

Comments
 (0)