Skip to content

Commit

Permalink
add game_number for thread titles
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Hoffman <[email protected]>
  • Loading branch information
Fustrate committed Jun 9, 2024
1 parent c1adadc commit 462a4e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/baseballbot/templates/game_threads/title.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def start_time_et = @game_thread.start_time_et.strftime('%-I:%M %p ET')

def opponent_name = @game_thread.opponent.name

def game_number
@game_thread.game_data.dig('teams', @game_thread.home? ? 'home' : 'away', 'record', 'gamesPlayed') + 1
end

def away_full_name = @game_thread.away_team.full_name

def away_name = @game_thread.away_team.name
Expand Down
6 changes: 6 additions & 0 deletions spec/baseballbot/templates/game_threads/title_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
expect(template.formatted_title).to eq 'Hello Gray, Js White, M World'
end

it 'shows the game number' do
template = game_thread_template(:preview, title: 'Game number {{game_number}}')

expect(template.formatted_title).to eq 'Game number 96'
end

it 'interpolates team records' do
template = game_thread_template(:preview, title: 'Hello {{away_record}} {{home_record}} World')

Expand Down

0 comments on commit 462a4e3

Please sign in to comment.