Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: 💍 Fix specs #83

Merged
merged 1 commit into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions :

This file was deleted.

9 changes: 8 additions & 1 deletion app/service/import_service/character.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ def rows # rubocop:disable Metrics/AbcSize
rows << [woven_star_foreign_key_id, woven_character, woven_yomi, woven_en]
end

rows
# 複数作品に出ているキャラをまとめる
# 基準は [1] の要素である「キャラ名」になる
# group_by で key に row[1] 、 value に row を持つハッシュを作る
# そして map で value の最初の要素を取り出す(全ての value が等しいという前提)
# #first なのでその時点で uniq と同等になる
rows.group_by { |row| row[1] }.map do |_, row|
row.first
end
end
end
end
2 changes: 1 addition & 1 deletion db/csv_on_sheet/characters/bases.csv
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ id,star_attr,s1,s1_yomi,s1_en,s2,s2_yomi,s2_en,s3,s3_yomi,s3_en,s4,s4_yomi,s4_en
22,天殺星,フー・スー・ルー,"","",ハンナ,"","",ハレック,"","",ゴー,"","",エルンスト,"","",ボッシュ,"","",ウッツェ,"","",李逵
23,天微星,キルキス,"","",キリィ,"","",クリス・ライトフェロー,"","",グレッチェン,"","",キリィ,"","",スフィール,"","",ニド,"","",史進
24,天究星,ミルイヒ・オッペンハイマー,"","",アニタ,"","",エステラ,"","",コンラッド,"","",シュラ・ヴァルヤ,"","",セレン,"","",ヤンセン,"","",穆弘
25,天退星,パーン,"","","アビズボア,フェザー,ジークフリート","","",セシル,"","",ジュエル,"","",シュン,"","",ジェイル,"","",ジーノ,"","",雷横
25,天退星,パーン,"","","アビズボア,フェザー,ジークフリード","","",セシル,"","",ジュエル,"","",シュン,"","",ジェイル,"","",ジーノ,"","",雷横
26,天寿星,ソニア・シューレン,"","",ナナミ,"","",ゲド,"","",カタリナ,"","",ベルナデット・イーガン,"","",ラジム,"","",イリア,"","",李俊
27,天剣星,アンジー,"","",リィナ,"","",メルヴィル,"","",ロウセン,"","",ヴォリガ,"","",ドロモン,"","",スニル,"","",阮小二
28,天平星,タイ・ホー,"","",タイ・ホー,"","",エース,"","",シラミネ,"","",ランス,"","",クロデキルド,"","",グワイニー,"","",張横
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,4 @@ id,is_available,product_name,character_name,facility_or_position_name,role_of_hq
181,TRUE,紡時,ユディエラ & ゴンボスレン,鎧鍛冶,"","",7
182,TRUE,紡時,リュセリ,ハンティング,"","",7
183,TRUE,紡時,ルルサ & シャルフ & ビョルン & ヌミストロ,厨房,"","",7
"",TRUE,幻水IV,ターニャ,図書室,"","",4
34 changes: 29 additions & 5 deletions spec/models/character_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,39 @@
expect(luc_records).to be_present
end

# FIXME: 直す
xit '名前は一つだけ存在すること' do
it '名前は一つだけ存在すること' do
expect(luc_records.size).to eq 1
end
end

xdescribe '"アビズボア,フェザー,ジークフリート"' do
it '分割されて記録されていること' do
expect(1 + 1).to eq 2
describe '間違えやすいキャラ' do
it '"ジークフリート" は存在しないこと' do
expect(Character.where(name: 'ジークフリート')).to be_blank
end

it '"ウインドウ" が存在すること' do
expect(Character.where(name: 'ウインドウ')).to be_present
end
end

describe '"アビズボア,フェザー,ジークフリード"' do
it 'まとめたレコードが記録されていないこと' do
expect(Character.where(name: 'アビズボア,フェザー,ジークフリード')).to be_blank
end

it 'アビズボア が一つのレコードとして記録されていること' do
expect(Character.find_by(name: 'アビズボア')).to be_present
expect(Character.where(name: 'アビズボア').size).to eq 1
end

it 'フェザー が一つのレコードとして記録されていること' do
expect(Character.find_by(name: 'フェザー')).to be_present
expect(Character.where(name: 'フェザー').size).to eq 1
end

it 'ジークフリード が一つのレコードとして記録されていること' do
expect(Character.find_by(name: 'ジークフリード')).to be_present
expect(Character.where(name: 'ジークフリード').size).to eq 1
end
end
end
2 changes: 1 addition & 1 deletion spec/models/star_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe Star, type: :model do
describe 'Star クラス' do
xit 'レコードの数が 108 であること' do
it 'レコードの数が 108 であること' do
stars = Star.all

expect(stars.count).to eq 108
Expand Down
2 changes: 1 addition & 1 deletion spec/service/download_csv_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

expect(
File.open('tmp/vault_test_check_first_row.csv').readline.chomp
).to eq 'id,seating_order,category,name,name_kana,name_en'
).to eq 'id,seating_order,category,name,yomi,name_en'
end

it '二行目(内容の行の一行目)の内容が期待どおりであること' do
Expand Down