1
0
Fork 1
impress/spec/models/alt_style_spec.rb
Emi Matchu 97ffffb67a Add configurable full name field to alt styles
Sigh, the "Valentine Plushie" series is messing with me again! It
doesn't follow the previously established pattern of the names being
"<series> <color> <species>", because in this case the base color is
considered "Valentine".

Okay, well! In this change we add `full_name` as an explicit database
field, and set the previous full name value as a fallback. (We also
extract the generic fallback logic into `ApplicationRecord`, to help us
express it more concisely.)

We also tweak `adjective_name` to be able to shorten custom `full_name`
values, too. That way, in the outfit editor, the Styles options show
correct values like "Cherub Plushie" for the "Cherub Plushie Acara".

I also make some changes in the outfit editor to better accommodate the
longer series names, to try to better handle long words but also to
just only use the first word of the series main name anyway. (Currently,
all series main names are one word, except "Valentine Plushie" becomes
"Valentine".)
2025-02-15 21:52:47 -08:00

112 lines
3 KiB
Ruby

require_relative '../rails_helper'
RSpec.describe AltStyle do
fixtures :colors, :species
describe "series name" do
subject(:alt_style) { AltStyle.new }
describe "for a new alt style" do
it("returns a placeholder value by default") do
expect(alt_style.series_name).to eq "<New?>"
end
it("has no real_series_name by default") do
expect(alt_style.real_series_name?).to be false
expect(alt_style.real_series_name).to be nil
end
end
describe "with a real series name" do
before { alt_style.real_series_name = "Nostalgic" }
it("returns the real series name") do
expect(alt_style.series_name).to eq "Nostalgic"
end
it("has a real_series_name field too") do
expect(alt_style.real_series_name?).to be true
expect(alt_style.real_series_name).to eq "Nostalgic"
end
end
end
describe "full name" do
subject(:alt_style) do
AltStyle.new(color: colors(:blue), species: species(:acara))
end
describe "for a new alt style" do
it("returns a placeholder value by default") do
expect(alt_style.full_name).to eq "<New?> Blue Acara"
end
it("has no real_full_name by default") do
expect(alt_style.real_full_name?).to be false
expect(alt_style.real_full_name).to be nil
end
end
describe "with a real series name, but no full name" do
before { alt_style.real_series_name = "Nostalgic" }
it("returns a placeholder value including the real series name") do
expect(alt_style.full_name).to eq "Nostalgic Blue Acara"
end
it("still has no real_full_name") do
expect(alt_style.real_full_name?).to be false
expect(alt_style.real_full_name).to eq nil
end
end
describe "with a real full name" do
before { alt_style.real_full_name = "Cute Lil Guy" }
it("returns the real full name") do
expect(alt_style.full_name).to eq "Cute Lil Guy"
end
it("has a real_full_name field too") do
expect(alt_style.real_full_name?).to be true
expect(alt_style.real_full_name).to eq "Cute Lil Guy"
end
end
end
describe "adjective name" do
subject(:alt_style) do
AltStyle.new(color: colors(:blue), species: species(:acara))
end
describe "for a new alt style" do
it("returns the placeholder series name and color name") do
expect(alt_style.adjective_name).to eq "<New?> Blue"
end
end
describe "with a real series name, but no full name" do
before { alt_style.series_name = "Nostalgic" }
it("returns the series name and color name") do
expect(alt_style.adjective_name).to eq "Nostalgic Blue"
end
end
describe "with a real full name that ends with the species name" do
before { alt_style.real_full_name = "Cute Lil Acara" }
it("returns the real full name minus the species") do
expect(alt_style.adjective_name).to eq "Cute Lil"
end
end
describe "with a real full name that does not end with the species name" do
before { alt_style.real_full_name = "Cute Lil Guy" }
it("returns the real full name") do
expect(alt_style.adjective_name).to eq "Cute Lil Guy"
end
end
end
end