File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 2
2
# suite and ammeter.
3
3
require 'rspec/rails/matchers'
4
4
5
+ if ::Rails ::VERSION ::MAJOR >= 7
6
+ require 'active_support/execution_context/test_helper'
7
+ end
8
+
5
9
module RSpec
6
10
module Rails
7
11
# @api public
@@ -12,7 +16,10 @@ module RailsExampleGroup
12
16
include RSpec ::Rails ::MinitestLifecycleAdapter
13
17
include RSpec ::Rails ::MinitestAssertionAdapter
14
18
include RSpec ::Rails ::FixtureSupport
15
- include RSpec ::Rails ::TaggedLoggingAdapter if ::Rails ::VERSION ::MAJOR >= 7
19
+ if ::Rails ::VERSION ::MAJOR >= 7
20
+ include RSpec ::Rails ::TaggedLoggingAdapter
21
+ include ActiveSupport ::ExecutionContext ::TestHelper
22
+ end
16
23
end
17
24
end
18
25
end
Original file line number Diff line number Diff line change @@ -5,5 +5,32 @@ module RSpec::Rails
5
5
expect ( described_class . private_instance_methods ) . to include ( :tagged_logger )
6
6
end
7
7
end
8
+
9
+ it 'does not leak context between example groups' , if : ::Rails ::VERSION ::MAJOR >= 7 do
10
+ groups =
11
+ [
12
+ RSpec ::Core ::ExampleGroup . describe ( "A group" ) do
13
+ include RSpec ::Rails ::RailsExampleGroup
14
+ specify { expect ( ActiveSupport ::ExecutionContext . to_h ) . to eq ( { } ) }
15
+ end ,
16
+ RSpec ::Core ::ExampleGroup . describe ( "A controller group" , type : :controller ) do
17
+ specify do
18
+ Rails . error . set_context ( foo : "bar" )
19
+ expect ( ActiveSupport ::ExecutionContext . to_h ) . to eq ( foo : "bar" )
20
+ end
21
+ end ,
22
+ RSpec ::Core ::ExampleGroup . describe ( "Another group" ) do
23
+ include RSpec ::Rails ::RailsExampleGroup
24
+ specify { expect ( ActiveSupport ::ExecutionContext . to_h ) . to eq ( { } ) }
25
+ end
26
+ ]
27
+
28
+ results =
29
+ groups . map do |group |
30
+ group . run ( failure_reporter ) ? true : failure_reporter . exceptions
31
+ end
32
+
33
+ expect ( results ) . to all be true
34
+ end
8
35
end
9
36
end
You can’t perform that action at this time.
0 commit comments