Skip to content

Commit

Permalink
Merge pull request #32 from leoamigood/la_game_start_msg
Browse files Browse the repository at this point in the history
Include language in game start message
  • Loading branch information
leoamigood authored Feb 15, 2017
2 parents 9658f12 + b1f86eb commit 04d9916
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/services/telegram/command/start.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class Start
class << self
def execute(channel)
TelegramMessenger.welcome(channel)
TelegramMessenger.ask_level(channel)
TelegramMessenger.ask_language(channel)

Telegram::CommandQueue.push{ TelegramMessenger.ask_language(channel) }
Telegram::CommandQueue.push{ TelegramMessenger.ask_level(channel) }
Telegram::CommandQueue.push{ TelegramMessenger.ask_length(channel) }
end
end
Expand Down
5 changes: 4 additions & 1 deletion app/services/telegram_messenger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def ask_length(channel)
end

def game_created(game)
"Game created with #{game.secret.length} letters in the secret word."
message = "Game created: #{game.secret.length} letters."
message += " Language: #{game.dictionary.lang}" if game.dictionary.present?

message
end

def guess(guess)
Expand Down
10 changes: 5 additions & 5 deletions spec/services/telegram_dispatcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
expect {
expect(TelegramDispatcher.handle(message)).to be
expect(TelegramMessenger).to have_received(:send_message).with(chat_id, /Welcome to Bulls and Cows!/).once
expect(TelegramMessenger).to have_received(:send_message).with(chat_id, 'Select game level:', markup).once
expect(TelegramMessenger).to have_received(:send_message).with(chat_id, 'Select game language:', markup).once
}.to change(Telegram::CommandQueue, :size).by(2)
end
end
Expand Down Expand Up @@ -54,19 +54,19 @@
end

it 'replies with a game created text' do
expect(TelegramDispatcher.handle(message)).to include('Game created with 6 letters in the secret word')
expect(TelegramDispatcher.handle(message)).to include('Game created: 6 letters')
end
end

context 'when /create multiple spaces in between <word> command received' do
let!(:message) { Telegram::Bot::Types::Message.new(text: '/create коитус') }
let!(:message) { Telegram::Bot::Types::Message.new(text: '/create коитус') }

before do
message.stub_chain(:chat, :id).and_return(chat_id)
end

it 'replies with a game created text' do
expect(TelegramDispatcher.handle(message)).to include('Game created with 6 letters in the secret word')
expect(TelegramDispatcher.handle(message)).to include('Game created: 6 letters.')
end
end

Expand All @@ -81,7 +81,7 @@
end

it 'replies with a game created text' do
expect(TelegramDispatcher.handle(message)).to include('Game created with 6 letters in the secret word')
expect(TelegramDispatcher.handle(message)).to include('Game created: 6 letters. Language: EN')
end
end

Expand Down

0 comments on commit 04d9916

Please sign in to comment.