|
1 | 1 | module RSpec::Rails
|
2 | 2 | RSpec.describe RailsExampleGroup do
|
3 |
| - if ::Rails::VERSION::MAJOR >= 7 |
4 |
| - class CurrentSample < ActiveSupport::CurrentAttributes |
5 |
| - attribute :request_id |
6 |
| - end |
7 |
| - |
8 |
| - it 'supports tagged_logger' do |
9 |
| - expect(described_class.private_instance_methods).to include(:tagged_logger) |
10 |
| - end |
| 3 | + it 'supports tagged_logger', if: ::Rails::VERSION::MAJOR >= 7 do |
| 4 | + expect(described_class.private_instance_methods).to include(:tagged_logger) |
11 | 5 | end
|
12 | 6 |
|
13 | 7 | it 'does not leak context between example groups', if: ::Rails::VERSION::MAJOR >= 7 do
|
@@ -37,17 +31,28 @@ class CurrentSample < ActiveSupport::CurrentAttributes
|
37 | 31 | expect(results).to all be true
|
38 | 32 | end
|
39 | 33 |
|
40 |
| - describe 'CurrentAttributes', order: :defined, if: ::Rails::VERSION::MAJOR >= 7 do |
41 |
| - include RSpec::Rails::RailsExampleGroup |
| 34 | + it 'will not leak ActiveSupport::CurrentAttributes between examples', if: ::Rails::VERSION::MAJOR >= 7 do |
| 35 | + group = |
| 36 | + RSpec::Core::ExampleGroup.describe("A group", order: :defined) do |
| 37 | + include RSpec::Rails::RailsExampleGroup |
42 | 38 |
|
43 |
| - it 'sets a current attribute' do |
44 |
| - CurrentSample.request_id = '123' |
45 |
| - expect(CurrentSample.request_id).to eq('123') |
46 |
| - end |
| 39 | + class CurrentSample < ActiveSupport::CurrentAttributes |
| 40 | + attribute :request_id |
| 41 | + end |
| 42 | + |
| 43 | + it 'sets a current attribute' do |
| 44 | + CurrentSample.request_id = '123' |
| 45 | + expect(CurrentSample.request_id).to eq('123') |
| 46 | + end |
| 47 | + |
| 48 | + it 'does not leak current attributes' do |
| 49 | + expect(CurrentSample.request_id).to eq(nil) |
| 50 | + end |
| 51 | + end |
47 | 52 |
|
48 |
| - it 'does not leak current attributes' do |
49 |
| - expect(CurrentSample.request_id).to eq(nil) |
50 |
| - end |
| 53 | + expect( |
| 54 | + group.run(failure_reporter) ? true : failure_reporter.exceptions |
| 55 | + ).to be true |
51 | 56 | end
|
52 | 57 | end
|
53 | 58 | end
|
0 commit comments