Skip to content

Commit b27a5b9

Browse files
authored
Address spec failures
The Rubocop failure I was unsure about but it seems from other specs here that a class can be defined in the top level block so we'll try that. The spec now only runs in Rails 7+ and only asserts against the defined attribute as that should suffice.
1 parent 808fef7 commit b27a5b9

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

spec/rspec/rails/example/rails_example_group_spec.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
module RSpec::Rails
2-
RSpec.describe RailsExampleGroup do
2+
RSpec.describe RailsExampleGroup do
33
if ::Rails::VERSION::MAJOR >= 7
4+
class CurrentSample < ActiveSupport::CurrentAttributes
5+
attribute :request_id
6+
end
7+
48
it 'supports tagged_logger' do
59
expect(described_class.private_instance_methods).to include(:tagged_logger)
610
end
@@ -33,22 +37,16 @@ module RSpec::Rails
3337
expect(results).to all be true
3438
end
3539

36-
describe 'CurrentAttributes', order: :defined do
40+
describe 'CurrentAttributes', order: :defined, if: ::Rails::VERSION::MAJOR >= 7 do
3741
include RSpec::Rails::RailsExampleGroup
3842

39-
class Current < ActiveSupport::CurrentAttributes
40-
attribute :request_id
41-
end
42-
4343
it 'sets a current attribute' do
44-
Current.request_id = '123'
45-
expect(Current.request_id).to eq('123')
46-
expect(Current.attributes).to eq(request_id: '123')
44+
CurrentSample.request_id = '123'
45+
expect(CurrentSample.request_id).to eq('123')
4746
end
4847

4948
it 'does not leak current attributes' do
50-
expect(Current.request_id).to eq(nil)
51-
expect(Current.attributes).to eq({})
49+
expect(CurrentSample.request_id).to eq(nil)
5250
end
5351
end
5452
end

0 commit comments

Comments
 (0)