Refactor item modeling spec, in anticipation of Item.is_modeled tests

I'm grouping some shared behaviors to pull into the different cases, so
that we can check the behaviors of a fully-modeled item vs a
not-fully-modeled item in *all* of the relevant cases.

Specifically, I'm planning to add `is:modeled` search filters, and
creating pending placeholder tests for them!
This commit is contained in:
Emi Matchu 2024-11-19 13:44:31 -08:00
parent 21eaf7b266
commit af5187edb6

View file

@ -36,10 +36,33 @@ RSpec.describe Item do
zones_restrict: "", zone:, body_id:)
end
shared_examples "a fully-modeled item" do
it("is considered fully modeled") { should be_predicted_fully_modeled }
it("predicts no more compatible bodies") do
expect(item.predicted_missing_body_ids).to be_empty
end
pending("appears in Item.is_modeled") do
expect(Item.is_modeled.find(item.id)).to be_present
end
pending("does not appear in Item.is_not_modeled") do
expect(Item.is_not_modeled.find(item.id)).to be_nil
end
end
shared_examples "a not-fully-modeled item" do
it("is not fully modeled") { should_not be_predicted_fully_modeled }
pending("does not appear in Item.is_modeled") do
expect(Item.is_modeled.find(item.id)).to be_nil
end
pending("appears in in Item.is_not_modeled") do
expect(Item.is_not_modeled.find(item.id)).to be_present
end
end
describe "an item without any modeling data" do
subject(:item) { items(:straw_hat) }
it("is not fully modeled") { should_not be_predicted_fully_modeled }
it_behaves_like "a not-fully-modeled item"
it("has no compatible body IDs") do
expect(item.compatible_body_ids).to be_empty
end
@ -55,13 +78,10 @@ RSpec.describe Item do
item.swf_assets << build_item_asset(zones(:wings), body_id: 1)
end
it("is considered fully modeled") { should be_predicted_fully_modeled }
it_behaves_like "a fully-modeled item"
it("has one compatible body ID") do
expect(item.compatible_body_ids).to contain_exactly(1)
end
it("predicts no more compatible bodies") do
expect(item.predicted_missing_body_ids).to be_empty
end
end
describe "an item with two species modeled" do
@ -75,7 +95,7 @@ RSpec.describe Item do
item.update_cached_fields
end
it("is not fully modeled") { should_not be_predicted_fully_modeled }
it_behaves_like "a not-fully-modeled item"
it("has two compatible body IDs") do
expect(item.compatible_body_ids).to contain_exactly(1, 2)
end
@ -97,13 +117,10 @@ RSpec.describe Item do
item.update_cached_fields
end
it("is fully modeled") { should be_predicted_fully_modeled }
it_behaves_like "a fully-modeled item"
it("is compatible with all standard body IDs") do
expect(item.compatible_body_ids).to contain_exactly(1, 2, 3, 4)
end
it("predicts no more compatible bodies") do
expect(item.predicted_missing_body_ids).to be_empty
end
end
describe "an item that fits all pets the same" do
@ -113,13 +130,10 @@ RSpec.describe Item do
item.swf_assets << build_item_asset(zones(:background), body_id: 0)
end
it("is fully modeled") { should be_predicted_fully_modeled }
it_behaves_like "a fully-modeled item"
it("is compatible with all bodies (body ID = 0)") do
expect(item.compatible_body_ids).to contain_exactly(0)
end
it("predicts no more compatible bodies") do
expect(item.predicted_missing_body_ids).to be_empty
end
end
describe "an item with one Maraquan pet modeled" do
@ -129,13 +143,10 @@ RSpec.describe Item do
item.swf_assets << build_item_asset(zones(:wings), body_id: 11)
end
it("is considered fully modeled") { should be_predicted_fully_modeled }
it_behaves_like "a fully-modeled item"
it("has one compatible body ID") do
expect(item.compatible_body_ids).to contain_exactly(11)
end
it("predicts no more compatible bodies") do
expect(item.predicted_missing_body_ids).to be_empty
end
end
describe "an item with two Maraquan pets modeled" do
@ -149,7 +160,7 @@ RSpec.describe Item do
item.update_cached_fields
end
it("is not fully modeled") { should_not be_predicted_fully_modeled }
it_behaves_like "a not-fully-modeled item"
it("has two compatible body IDs") do
expect(item.compatible_body_ids).to contain_exactly(11, 12)
end
@ -171,13 +182,10 @@ RSpec.describe Item do
item.update_cached_fields
end
it("is fully modeled") { should be_predicted_fully_modeled }
it_behaves_like "a fully-modeled item"
it("is compatible with all Maraquan body IDs") do
expect(item.compatible_body_ids).to contain_exactly(11, 12, 13, 4)
end
it("predicts no more compatible bodies") do
expect(item.predicted_missing_body_ids).to be_empty
end
end
end
end