0
0
Fork 0

Fix RSpec/ContextWording cop (#24739)

This commit is contained in:
Matt Jankowski 2023-05-03 23:49:08 -04:00 committed by GitHub
parent cf18cc2891
commit 710745e16b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
105 changed files with 559 additions and 668 deletions

View file

@ -19,7 +19,7 @@ RSpec.describe Setting, type: :model do
let(:key) { 'key' }
context 'rails_initialized? is falsey' do
context 'when rails_initialized? is falsey' do
let(:rails_initialized) { false }
it 'calls RailsSettings::Base#[]' do
@ -28,7 +28,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'rails_initialized? is truthy' do
context 'when rails_initialized? is truthy' do
before do
allow(RailsSettings::Base).to receive(:cache_key).with(key, nil).and_return(cache_key)
end
@ -42,7 +42,7 @@ RSpec.describe Setting, type: :model do
described_class[key]
end
context 'Rails.cache does not exists' do
context 'when Rails.cache does not exists' do
before do
allow(RailsSettings::Settings).to receive(:object).with(key).and_return(object)
allow(described_class).to receive(:default_settings).and_return(default_settings)
@ -60,11 +60,11 @@ RSpec.describe Setting, type: :model do
described_class[key]
end
context 'RailsSettings::Settings.object returns truthy' do
context 'when RailsSettings::Settings.object returns truthy' do
let(:object) { db_val }
let(:db_val) { double(value: 'db_val') }
context 'default_value is a Hash' do
context 'when default_value is a Hash' do
let(:default_value) { { default_value: 'default_value' } }
it 'calls default_value.with_indifferent_access.merge!' do
@ -75,7 +75,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'default_value is not a Hash' do
context 'when default_value is not a Hash' do
let(:default_value) { 'default_value' }
it 'returns db_val.value' do
@ -84,7 +84,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'RailsSettings::Settings.object returns falsey' do
context 'when RailsSettings::Settings.object returns falsey' do
let(:object) { nil }
it 'returns default_settings[key]' do
@ -93,7 +93,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'Rails.cache exists' do
context 'when Rails.cache exists' do
before do
Rails.cache.write(cache_key, cache_value)
end
@ -130,7 +130,7 @@ RSpec.describe Setting, type: :model do
expect(described_class.all_as_records).to be_a Hash
end
context 'records includes Setting with var as the key' do
context 'when records includes Setting with var as the key' do
let(:records) { [original_setting] }
it 'includes the original Setting' do
@ -139,10 +139,10 @@ RSpec.describe Setting, type: :model do
end
end
context 'records includes nothing' do
context 'when records includes nothing' do
let(:records) { [] }
context 'default_value is not a Hash' do
context 'when default_value is not a Hash' do
it 'includes Setting with value of default_value' do
setting = described_class.all_as_records[key]
@ -152,7 +152,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'default_value is a Hash' do
context 'when default_value is a Hash' do
let(:default_value) { { 'foo' => 'fuga' } }
it 'returns {}' do
@ -169,7 +169,7 @@ RSpec.describe Setting, type: :model do
allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled)
end
context 'RailsSettings::Default.enabled? is false' do
context 'when RailsSettings::Default.enabled? is false' do
let(:enabled) { false }
it 'returns {}' do
@ -177,7 +177,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'RailsSettings::Settings.enabled? is true' do
context 'when RailsSettings::Settings.enabled? is true' do
let(:enabled) { true }
it 'returns instance of RailsSettings::Default' do