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:
parent
21eaf7b266
commit
af5187edb6
1 changed files with 31 additions and 23 deletions
|
@ -36,10 +36,33 @@ RSpec.describe Item do
|
||||||
zones_restrict: "", zone:, body_id:)
|
zones_restrict: "", zone:, body_id:)
|
||||||
end
|
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
|
describe "an item without any modeling data" do
|
||||||
subject(:item) { items(:straw_hat) }
|
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
|
it("has no compatible body IDs") do
|
||||||
expect(item.compatible_body_ids).to be_empty
|
expect(item.compatible_body_ids).to be_empty
|
||||||
end
|
end
|
||||||
|
@ -55,13 +78,10 @@ RSpec.describe Item do
|
||||||
item.swf_assets << build_item_asset(zones(:wings), body_id: 1)
|
item.swf_assets << build_item_asset(zones(:wings), body_id: 1)
|
||||||
end
|
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
|
it("has one compatible body ID") do
|
||||||
expect(item.compatible_body_ids).to contain_exactly(1)
|
expect(item.compatible_body_ids).to contain_exactly(1)
|
||||||
end
|
end
|
||||||
it("predicts no more compatible bodies") do
|
|
||||||
expect(item.predicted_missing_body_ids).to be_empty
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "an item with two species modeled" do
|
describe "an item with two species modeled" do
|
||||||
|
@ -75,7 +95,7 @@ RSpec.describe Item do
|
||||||
item.update_cached_fields
|
item.update_cached_fields
|
||||||
end
|
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
|
it("has two compatible body IDs") do
|
||||||
expect(item.compatible_body_ids).to contain_exactly(1, 2)
|
expect(item.compatible_body_ids).to contain_exactly(1, 2)
|
||||||
end
|
end
|
||||||
|
@ -97,13 +117,10 @@ RSpec.describe Item do
|
||||||
item.update_cached_fields
|
item.update_cached_fields
|
||||||
end
|
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
|
it("is compatible with all standard body IDs") do
|
||||||
expect(item.compatible_body_ids).to contain_exactly(1, 2, 3, 4)
|
expect(item.compatible_body_ids).to contain_exactly(1, 2, 3, 4)
|
||||||
end
|
end
|
||||||
it("predicts no more compatible bodies") do
|
|
||||||
expect(item.predicted_missing_body_ids).to be_empty
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "an item that fits all pets the same" do
|
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)
|
item.swf_assets << build_item_asset(zones(:background), body_id: 0)
|
||||||
end
|
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
|
it("is compatible with all bodies (body ID = 0)") do
|
||||||
expect(item.compatible_body_ids).to contain_exactly(0)
|
expect(item.compatible_body_ids).to contain_exactly(0)
|
||||||
end
|
end
|
||||||
it("predicts no more compatible bodies") do
|
|
||||||
expect(item.predicted_missing_body_ids).to be_empty
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "an item with one Maraquan pet modeled" do
|
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)
|
item.swf_assets << build_item_asset(zones(:wings), body_id: 11)
|
||||||
end
|
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
|
it("has one compatible body ID") do
|
||||||
expect(item.compatible_body_ids).to contain_exactly(11)
|
expect(item.compatible_body_ids).to contain_exactly(11)
|
||||||
end
|
end
|
||||||
it("predicts no more compatible bodies") do
|
|
||||||
expect(item.predicted_missing_body_ids).to be_empty
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "an item with two Maraquan pets modeled" do
|
describe "an item with two Maraquan pets modeled" do
|
||||||
|
@ -149,7 +160,7 @@ RSpec.describe Item do
|
||||||
item.update_cached_fields
|
item.update_cached_fields
|
||||||
end
|
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
|
it("has two compatible body IDs") do
|
||||||
expect(item.compatible_body_ids).to contain_exactly(11, 12)
|
expect(item.compatible_body_ids).to contain_exactly(11, 12)
|
||||||
end
|
end
|
||||||
|
@ -171,13 +182,10 @@ RSpec.describe Item do
|
||||||
item.update_cached_fields
|
item.update_cached_fields
|
||||||
end
|
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
|
it("is compatible with all Maraquan body IDs") do
|
||||||
expect(item.compatible_body_ids).to contain_exactly(11, 12, 13, 4)
|
expect(item.compatible_body_ids).to contain_exactly(11, 12, 13, 4)
|
||||||
end
|
end
|
||||||
it("predicts no more compatible bodies") do
|
|
||||||
expect(item.predicted_missing_body_ids).to be_empty
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue