@@ -33,38 +33,20 @@ module RSpec::Rails
33
33
expect ( results ) . to all be true
34
34
end
35
35
36
- describe 'CurrentAttributes' do
37
- let ( :current_class ) do
38
- Class . new ( ActiveSupport ::CurrentAttributes ) do
39
- attribute :request_id
40
- end
36
+ describe 'CurrentAttributes' , order : :defined do
37
+ class Current < ActiveSupport ::CurrentAttributes
38
+ attribute :request_id
41
39
end
42
40
43
- it 'does not leak current attributes between example groups' , if : ::Rails ::VERSION ::MAJOR >= 7 do
44
- groups =
45
- [
46
- RSpec ::Core ::ExampleGroup . describe ( "A group" ) do
47
- include RSpec ::Rails ::RailsExampleGroup
48
- specify { expect ( current_class . attributes ) . to eq ( { } ) }
49
- end ,
50
- RSpec ::Core ::ExampleGroup . describe ( "A controller group" , type : :controller ) do
51
- specify do
52
- current_class . request_id = "123"
53
- expect ( current_class . attributes ) . to eq ( request_id : "123" )
54
- end
55
- end ,
56
- RSpec ::Core ::ExampleGroup . describe ( "Another group" ) do
57
- include RSpec ::Rails ::RailsExampleGroup
58
- specify { expect ( current_class . attributes ) . to eq ( { } ) }
59
- end
60
- ]
61
-
62
- results =
63
- groups . map do |group |
64
- group . run ( failure_reporter ) ? true : failure_reporter . exceptions
65
- end
66
-
67
- expect ( results ) . to all be true
41
+ it 'sets a current attribute' do
42
+ Current . request_id = '123'
43
+ expect ( Current . request_id ) . to eq ( '123' )
44
+ expect ( Current . attributes ) . to eq ( request_id : '123' )
45
+ end
46
+
47
+ it 'does not leak current attributes' do
48
+ expect ( Current . request_id ) . to eq ( nil )
49
+ expect ( Current . attributes ) . to eq ( { } )
68
50
end
69
51
end
70
52
end
0 commit comments