From aa83818b0eddf0f9e79a8b11e355ec05265713dc Mon Sep 17 00:00:00 2001 From: Tomasz Donarski Date: Fri, 27 Oct 2023 13:36:26 +0200 Subject: [PATCH] Rename variables in tests --- .../models/spree/admin/main_menu/root_spec.rb | 14 +++++----- .../spree/admin/main_menu/section_spec.rb | 12 ++++----- spec/models/spree/admin/tabs/root_spec.rb | 4 +-- .../admin/manipulation_and_query_methods.rb | 26 +++++++++---------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/spec/models/spree/admin/main_menu/root_spec.rb b/spec/models/spree/admin/main_menu/root_spec.rb index 9790f11a7e..d8376b5528 100644 --- a/spec/models/spree/admin/main_menu/root_spec.rb +++ b/spec/models/spree/admin/main_menu/root_spec.rb @@ -3,17 +3,17 @@ module Spree module Admin describe MainMenu::Root, type: :model do - let(:root) { described_class.new } + let(:class_under_test) { described_class.new } let(:items) { [] } before do - items.each { |i| root.add(i) } + items.each { |i| class_under_test.add(i) } end it_behaves_like 'implements item manipulation and query methods' describe '#key' do - subject { root.key } + subject { class_under_test.key } it 'returns root' do expect(subject).to eq('root') @@ -21,7 +21,7 @@ module Admin end describe '#label_translation_key' do - subject { root.label_translation_key } + subject { class_under_test.label_translation_key } it 'returns root' do expect(subject).to eq('root') @@ -29,7 +29,7 @@ module Admin end describe '#icon_key' do - subject { root.icon_key } + subject { class_under_test.icon_key } it 'returns nil' do expect(subject).to be_nil @@ -37,7 +37,7 @@ module Admin end describe '#available?' do - subject { root.available?(ability, store) } + subject { class_under_test.available?(ability, store) } let(:ability) { double } let(:store) { double } @@ -48,7 +48,7 @@ module Admin end describe '#add_to_section' do - subject { root.add_to_section(section_key, item) } + subject { class_under_test.add_to_section(section_key, item) } let(:items) { [section] } let(:section) { double(key: section_key) } diff --git a/spec/models/spree/admin/main_menu/section_spec.rb b/spec/models/spree/admin/main_menu/section_spec.rb index c3a3616e6a..e624ada5b1 100644 --- a/spec/models/spree/admin/main_menu/section_spec.rb +++ b/spec/models/spree/admin/main_menu/section_spec.rb @@ -3,7 +3,7 @@ module Spree module Admin describe MainMenu::Section, type: :model do - let(:section) { described_class.new(key, label_translation_key, icon_key, availability_checks, items) } + let(:class_under_test) { described_class.new(key, label_translation_key, icon_key, availability_checks, items) } let(:key) { 'test-key' } let(:label_translation_key) { 'test-translation-key' } let(:icon_key) { 'icon-key' } @@ -13,7 +13,7 @@ module Admin it_behaves_like 'implements item manipulation and query methods' describe '#key' do - subject { section.key } + subject { class_under_test.key } it 'returns key' do expect(subject).to eq(key) @@ -21,7 +21,7 @@ module Admin end describe '#label_translation_key' do - subject { section.label_translation_key } + subject { class_under_test.label_translation_key } it 'returns translation key' do expect(subject).to eq(label_translation_key) @@ -29,7 +29,7 @@ module Admin end describe '#icon_key' do - subject { section.icon_key } + subject { class_under_test.icon_key } it 'returns icon mey' do expect(subject).to eq(icon_key) @@ -37,7 +37,7 @@ module Admin end describe '#available?' do - subject { section.available?(ability, store) } + subject { class_under_test.available?(ability, store) } let(:ability) { double} let(:store) { double } @@ -66,7 +66,7 @@ module Admin end describe '#children?' do - subject { section.children? } + subject { class_under_test.children? } context 'when there are child items' do let(:items) { [double] } diff --git a/spec/models/spree/admin/tabs/root_spec.rb b/spec/models/spree/admin/tabs/root_spec.rb index 9057af6443..2c4effd0df 100644 --- a/spec/models/spree/admin/tabs/root_spec.rb +++ b/spec/models/spree/admin/tabs/root_spec.rb @@ -3,11 +3,11 @@ module Spree module Admin describe Tabs::Root, type: :model do - let(:root) { described_class.new } + let(:class_under_test) { described_class.new } let(:items) { [] } before do - items.each { |i| root.add(i) } + items.each { |i| class_under_test.add(i) } end it_behaves_like 'implements item manipulation and query methods' diff --git a/spec/support/admin/manipulation_and_query_methods.rb b/spec/support/admin/manipulation_and_query_methods.rb index 72479794d3..1942736657 100644 --- a/spec/support/admin/manipulation_and_query_methods.rb +++ b/spec/support/admin/manipulation_and_query_methods.rb @@ -1,13 +1,13 @@ RSpec.shared_examples "implements item manipulation and query methods" do describe '#add' do - subject { root.add(item) } + subject { class_under_test.add(item) } let(:item) { double(key: 'test') } context "when there's no item with a particular key" do it 'appends an item' do subject - expect(root.items).to include(item) + expect(class_under_test.items).to include(item) end end @@ -21,7 +21,7 @@ end describe '#child_with_key?' do - subject { root.child_with_key?(key) } + subject { class_under_test.child_with_key?(key) } let(:key) { 'key' } context 'when an item with given key exists' do @@ -42,7 +42,7 @@ end describe '#remove' do - subject { root.remove(key) } + subject { class_under_test.remove(key) } let(:key) { 'key' } let(:other_key) { 'other-key' } @@ -51,8 +51,8 @@ it 'removes the item' do subject - expect(root.items.count).to eq(1) - expect(root.items.first.key).to eq(other_key) + expect(class_under_test.items.count).to eq(1) + expect(class_under_test.items.first.key).to eq(other_key) end end @@ -66,7 +66,7 @@ end describe '#item_for_key' do - subject { root.item_for_key(key) } + subject { class_under_test.item_for_key(key) } let(:key) { 'key' } context 'when an item with given key exists' do @@ -88,7 +88,7 @@ end describe '#insert_before' do - subject { root.insert_before(existing_key, item) } + subject { class_under_test.insert_before(existing_key, item) } let(:item) { double(key: inserted_key) } let(:inserted_key) { 'test-item' } @@ -113,14 +113,14 @@ it 'inserts the item before the other item' do subject - expect(root.items.count).to eq(3) - expect(root.items[1].key).to eq(inserted_key) + expect(class_under_test.items.count).to eq(3) + expect(class_under_test.items[1].key).to eq(inserted_key) end end end describe '#insert_after' do - subject { root.insert_after(existing_key, item) } + subject { class_under_test.insert_after(existing_key, item) } let(:item) { double(key: inserted_key) } let(:inserted_key) { 'test-item' } @@ -145,8 +145,8 @@ it 'inserts the item after the other item' do subject - expect(root.items.count).to eq(3) - expect(root.items[1].key).to eq(inserted_key) + expect(class_under_test.items.count).to eq(3) + expect(class_under_test.items[1].key).to eq(inserted_key) end end end