describe "#first_character_name" do
# when
subject { user.first_character_name }
[
[[], nil],
[[{ created_at: Time.current, name: nil, status: :draft }], nil],
[[{ created_at: Time.current, name: "Joe" }, { created_at: 1.minute.ago, name: "Doe", status: :draft }], "Doe"],
[[{ created_at: Time.current, name: "Joe", status: :draft }, { created_at: 1.minute.ago, name: "Doe" }], "Doe"],
[[{ created_at: Time.current, name: "Joe" }, { created_at: 1.minute.ago, name: "Doe" }], "Doe"]
].each do |characters_attrs, expected_name|
context "with #{characters_attrs.map(&:to_s).join ', '}" do
# when
let(:characters) { characters_attrs.map { |character_attrs| build :character, character_attrs } }
# then
it { is_expected.to eq expected_name }
end
end
end