Skip to content

Commit

Permalink
Merge pull request #399 from bcdice/test_sort_key
Browse files Browse the repository at this point in the history
SORT_KEYをテストする
  • Loading branch information
ysakasin authored Mar 20, 2021
2 parents 38595f6 + 36a9a1a commit 2ec6679
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Cthulhu7th_ChineseTraditional < Base
NAME = '克蘇魯神話第7版'

# ゲームシステム名の読みがな
SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話'
SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話第7版'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Cthulhu7th_Korean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Cthulhu7th_Korean < Base
NAME = '크툴루의 부름 7판'

# ゲームシステム名の読みがな
SORT_KEY = '国際化:Korean:크툴루'
SORT_KEY = '国際化:Korean:크툴루의 부름 7판'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Cthulhu_ChineseTraditional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Cthulhu_ChineseTraditional < Cthulhu
NAME = '克蘇魯神話'

# ゲームシステム名の読みがな
SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話7'
SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Cthulhu_Korean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Cthulhu_Korean < Cthulhu
NAME = '크툴루'

# ゲームシステム名の読みがな
SORT_KEY = '国際化:Korean:크툴루의부름7'
SORT_KEY = '国際化:Korean:크툴루'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/MeikyuKingdomBasic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MeikyuKingdomBasic < MeikyuKingdom
NAME = '迷宮キングダム 基本ルールブック'

# ゲームシステム名の読みがな
SORT_KEY = 'めいきゆうきんくたむ きほんるうるふつく'
SORT_KEY = 'めいきゆうきんくたむきほんるうるふつく'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
20 changes: 20 additions & 0 deletions test/test_sort_key.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require "test/unit"
require "bcdice"
require "bcdice/game_system"

class TestSortKey < Test::Unit::TestCase
HIRAGANA_BASIC_CHARS = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん"

data do
BCDice.all_game_systems.map { |s| [s::ID, s::SORT_KEY] }.to_h
end
def test_sort_key(sort_key)
assert_match(
/\A(?:[#{HIRAGANA_BASIC_CHARS}][\d.A-Za-z#{HIRAGANA_BASIC_CHARS}]*|国際化:[\w ]+:.+|\*たいすほつと)\z/,
sort_key,
"SORT_KEY \"#{sort_key}\" はSORT_KEYの規約に違反しています。規約は docs/dicebot_sort_key.md を参照してください"
)
end
end

0 comments on commit 2ec6679

Please sign in to comment.