@@ -33,38 +33,20 @@ module RSpec::Rails
3333 expect ( results ) . to all be true
3434 end
3535
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
4139 end
4240
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 ( { } )
6850 end
6951 end
7052 end
0 commit comments