From 89025274384fc502940161cc3ffd02cdbc755b52 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Thu, 24 Oct 2024 15:37:57 -0700 Subject: [PATCH] Basic modeling spec for my pet, matts_bat No items yet, just putting in the very basics of biology, more shortform than the Thyassa case --- spec/fixtures/colors.yml | 3 + spec/fixtures/species.yml | 3 + spec/models/pet_spec.rb | 22 ++- spec/support/mocks/custom_pets/matts_bat.json | 186 ++++++++++++++++++ 4 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 spec/support/mocks/custom_pets/matts_bat.json diff --git a/spec/fixtures/colors.yml b/spec/fixtures/colors.yml index b31ffcc9..8b22ddd5 100644 --- a/spec/fixtures/colors.yml +++ b/spec/fixtures/colors.yml @@ -1,3 +1,6 @@ purple: id: 57 name: purple +striped: + id: 77 + name: striped diff --git a/spec/fixtures/species.yml b/spec/fixtures/species.yml index 04ce807b..15711ad6 100644 --- a/spec/fixtures/species.yml +++ b/spec/fixtures/species.yml @@ -1,3 +1,6 @@ +blumaroo: + id: 3 + name: blumaroo chia: id: 7 name: chia diff --git a/spec/models/pet_spec.rb b/spec/models/pet_spec.rb index d0352cee..09030e97 100644 --- a/spec/models/pet_spec.rb +++ b/spec/models/pet_spec.rb @@ -5,7 +5,7 @@ require_relative '../support/matchers/a_record_matching' RSpec.describe Pet, type: :model do fixtures :colors, :species, :zones - context "#load" do + context ".load" do context "for thyassa, the Purple Chia" do subject(:pet) { Pet.load "thyassa" } @@ -102,5 +102,25 @@ RSpec.describe Pet, type: :model do end end end + + context "for matts_bat, a pet with basic items" do + subject(:pet) { Pet.load("matts_bat") } + + # We do simpler checks for biology, and trust the Thyassa case to cover it. + it("is named matts_bat") { expect(pet.name).to eq "matts_bat" } + it("is a Striped Blumaroo") { expect(pet.pet_type.human_name).to eq "Striped Blumaroo" } + + describe "its biology assets" do + subject(:biology_assets) { pet.pet_state.swf_assets } + let(:asset_ids) { biology_assets.map(&:remote_id) } + + it("are all new") { expect(biology_assets.all?(&:new_record?)).to be true } + it("match the expected IDs") do + pet.save! # TODO: I wish this were set up before saving. + + expect(asset_ids).to contain_exactly(331, 332, 333, 23760, 23411) + end + end + end end end diff --git a/spec/support/mocks/custom_pets/matts_bat.json b/spec/support/mocks/custom_pets/matts_bat.json new file mode 100644 index 00000000..4662133c --- /dev/null +++ b/spec/support/mocks/custom_pets/matts_bat.json @@ -0,0 +1,186 @@ +{ + "custom_pet": { + "name": "matts_bat", + "owner": "matchu1993", + "slot": 1.0, + "scale": 0.5, + "muted": true, + "body_id": 47.0, + "species_id": 3.0, + "color_id": 77.0, + "alt_style": false, + "alt_color": 77.0, + "style_closet_id": null, + "biology_by_zone": { + "30": { + "part_id": 331.0, + "zone_id": 30.0, + "asset_url": "https://images.neopets.com/cp/bio/swf/000/000/000/331_08520cfb4c.swf", + "manifest": "https://images.neopets.com/cp/bio/data/000/000/000/331_08520cfb4c/manifest.json", + "zones_restrict": "0000000000000000000000000000000000000000000000000000" + }, + "15": { + "part_id": 332.0, + "zone_id": 15.0, + "asset_url": "https://images.neopets.com/cp/bio/swf/000/000/000/332_cb12110826.swf", + "manifest": "https://images.neopets.com/cp/bio/data/000/000/000/332_cb12110826/manifest.json", + "zones_restrict": "0000000000000000000000000000000000000000000000000000" + }, + "5": { + "part_id": 333.0, + "zone_id": 5.0, + "asset_url": "https://images.neopets.com/cp/bio/swf/000/000/000/333_990e61a81a.swf", + "manifest": "https://images.neopets.com/cp/bio/data/000/000/000/333_990e61a81a/manifest.json", + "zones_restrict": "0000000000000000000000000000000000000000000000000000" + }, + "34": { + "part_id": 23760.0, + "zone_id": 34.0, + "asset_url": "https://images.neopets.com/cp/bio/swf/000/000/023/23760_400c08010f.swf", + "manifest": "https://images.neopets.com/cp/bio/data/000/000/023/23760_400c08010f/manifest.json", + "zones_restrict": "0000000000000000000000000000000000000000000000000000" + }, + "33": { + "part_id": 23411.0, + "zone_id": 33.0, + "asset_url": "https://images.neopets.com/cp/bio/swf/000/000/023/23411_7313164efd.swf", + "manifest": "https://images.neopets.com/cp/bio/data/000/000/023/23411_7313164efd/manifest.json", + "zones_restrict": "0000000000000000000000000000000000000000000000000000" + } + }, + "equipped_by_zone": { + "35": { + "asset_id": 16933.0, + "zone_id": 35.0, + "closet_obj_id": 2549145.0 + }, + "23": { + "asset_id": 108567.0, + "zone_id": 23.0, + "closet_obj_id": 16955628.0 + }, + "3": { + "asset_id": 410722.0, + "zone_id": 3.0, + "closet_obj_id": 17147987.0 + } + }, + "original_biology": [ + + ] + }, + "closet_items": { + "2549145": { + "closet_obj_id": 2549145.0, + "obj_info_id": 39552.0, + "applied_to": "matts_bat", + "is_wishlist": false, + "expiration": "N/A" + }, + "16955628": { + "closet_obj_id": 16955628.0, + "obj_info_id": 53874.0, + "applied_to": "matts_bat", + "is_wishlist": false, + "expiration": "N/A" + }, + "17147987": { + "closet_obj_id": 17147987.0, + "obj_info_id": 71706.0, + "applied_to": "matts_bat", + "is_wishlist": false, + "expiration": "N/A" + } + }, + "object_info_registry": { + "39552": { + "obj_info_id": 39552.0, + "assets_by_zone": { + "35": 16933.0 + }, + "zones_restrict": "0000000000000000000000000000000000000000000000000000", + "is_compatible": true, + "is_paid": true, + "thumbnail_url": "https://images.neopets.com/items/mall_springyeyeglasses.gif", + "name": "Springy Eye Glasses", + "description": "Hey, keep your eyes in your head!", + "category": "Clothes", + "type": "Clothes", + "rarity": "Artifact", + "rarity_index": 500.0, + "price": 0.0, + "weight_lbs": 1.0, + "species_support": [ + 3.0 + ], + "converted": true + }, + "53874": { + "obj_info_id": 53874.0, + "assets_by_zone": { + "23": 108567.0 + }, + "zones_restrict": "0000000000000000000000000000000000000000000000000000", + "is_compatible": true, + "is_paid": false, + "thumbnail_url": "https://images.neopets.com/items/clo_404_shirt.gif", + "name": "404 Shirt", + "description": "When Neopets is down, the shirt comes on!", + "category": "Clothes", + "type": "Clothes", + "rarity": "Rare", + "rarity_index": 88.0, + "price": 1701.0, + "weight_lbs": 1.0, + "species_support": [ + 3.0 + ], + "converted": true + }, + "71706": { + "obj_info_id": 71706.0, + "assets_by_zone": { + "3": 410722.0 + }, + "zones_restrict": "0000000000000000000000000000000000000000000000000000", + "is_compatible": true, + "is_paid": false, + "thumbnail_url": "https://images.neopets.com/items/gif_roof_onthe_fg.gif", + "name": "On the Roof Background", + "description": "Who is that on the roof?! Could it be...?", + "category": "Special", + "type": "Mystical Surroundings", + "rarity": "Special", + "rarity_index": 101.0, + "price": 0.0, + "weight_lbs": 1.0, + "species_support": [ + + ], + "converted": true + } + }, + "object_asset_registry": { + "16933": { + "asset_id": 16933.0, + "zone_id": 35.0, + "asset_url": "https://images.neopets.com/cp/items/swf/000/000/016/16933_0833353c4f.swf", + "obj_info_id": 39552.0, + "manifest": "https://images.neopets.com/cp/items/data/000/000/016/16933_0833353c4f/manifest.json?v=1706" + }, + "108567": { + "asset_id": 108567.0, + "zone_id": 23.0, + "asset_url": "https://images.neopets.com/cp/items/swf/000/000/108/108567_ee88141325.swf", + "obj_info_id": 53874.0, + "manifest": "https://images.neopets.com/cp/items/data/000/000/108/108567_ee88141325/manifest.json?v=1706" + }, + "410722": { + "asset_id": 410722.0, + "zone_id": 3.0, + "asset_url": "https://images.neopets.com/cp/items/swf/000/000/410/410722_3bcd2f5e11.swf", + "obj_info_id": 71706.0, + "manifest": "https://images.neopets.com/cp/items/data/000/000/410/410722_3bcd2f5e11/manifest.json?v=1706" + } + } +}