From 7a837edaf69fbf102c521fdcc1be5c461c87a663 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Fri, 25 Oct 2024 13:38:02 -0700 Subject: [PATCH] Use alias `they` in specs instead of `it`, when it reads better --- spec/models/pet_spec.rb | 30 +++++++++++++++--------------- spec/spec_helper.rb | 4 ++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/spec/models/pet_spec.rb b/spec/models/pet_spec.rb index 68a49567..92f5eaa5 100644 --- a/spec/models/pet_spec.rb +++ b/spec/models/pet_spec.rb @@ -39,15 +39,15 @@ RSpec.describe Pet, type: :model do subject(:biology_assets) { pet_state.swf_assets } let(:asset_ids) { biology_assets.map(&:remote_id) } - it("are all new") do + they("are all new") do pending("Currently, pets must be saved before assets are assigned.") should all be_new_record end - it("match the expected IDs") do + they("match the expected IDs") do expect(asset_ids).to contain_exactly(10083, 11613, 14187, 14189) end - it("are saved when saving the pet") { pet.save!; should all be_persisted } - it("have the expected asset metadata") do + they("are saved when saving the pet") { pet.save!; should all be_persisted } + they("have the expected asset metadata") do expect(pet_state.swf_assets).to contain_exactly( a_record_matching( type: "biology", @@ -127,26 +127,26 @@ RSpec.describe Pet, type: :model do subject(:biology_assets) { pet.pet_state.swf_assets } let(:asset_ids) { biology_assets.map(&:remote_id) } - it("are all new") do + they("are all new") do pending("Currently, pets must be saved before assets are assigned.") should all be_new_record end - it("match the expected IDs") do + they("match the expected IDs") do expect(asset_ids).to contain_exactly(331, 332, 333, 23760, 23411) end - it("are saved when saving the pet") { pet.save!; should all be_persisted } + they("are saved when saving the pet") { pet.save!; should all be_persisted } end describe "its items" do subject(:items) { pet.items } let(:item_ids) { items.map(&:id) } - it("are all new") { should all be_new_record } - it("match the expected IDs") do + they("are all new") { should all be_new_record } + they("match the expected IDs") do expect(item_ids).to contain_exactly(39552, 53874, 71706) end - it("are saved when saving the pet") { pet.save! ; should all be_persisted } - it("have the expected item metadata") do + they("are saved when saving the pet") { pet.save! ; should all be_persisted } + they("have the expected item metadata") do should contain_exactly( a_record_matching( id: 39552, @@ -203,15 +203,15 @@ RSpec.describe Pet, type: :model do subject(:item_assets) { assets_by_item.values.flatten(1) } let(:asset_ids) { item_assets.map(&:remote_id) } - it("are all new") do + they("are all new") do pending("Currently, pets must be saved before assets are assigned.") should all be_new_record end - it("match the expected IDs") do + they("match the expected IDs") do expect(asset_ids).to contain_exactly(16933, 108567, 410722) end - it("are saved when saving the pet") { pet.save! ; should all be_persisted } - it("match the expected metadata") do + they("are saved when saving the pet") { pet.save! ; should all be_persisted } + they("match the expected metadata") do expect(assets_by_item).to match( 39552 => a_collection_containing_exactly( a_record_matching( diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 424c4fca..ddce1551 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -27,6 +27,10 @@ RSpec.configure do |config| mocks.verify_partial_doubles = true end + # In our specs, we describe plural collections sometimes, so we add "they" + # as an alias for "it". + config.alias_example_to :they + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will # have no way to turn it off -- the option exists only for backwards # compatibility in RSpec 3). It causes shared context metadata to be