Fix failing spec

This commit is contained in:
Rick Carlino 2015-05-12 06:51:22 -05:00
parent 259a220c85
commit e6a48b8d00
2 changed files with 7 additions and 7 deletions

View file

@ -15,7 +15,7 @@ class SingleCommandController < AbstractController
def call
@cmd = (message.payload || {})
key = cmd.fetch("command", {})["action"].to_s.downcase
key = @cmd["action"].to_s.gsub("_", " ").downcase
action = AVAILABLE_ACTIONS.fetch(key, :unknown).to_sym
send(action)
reply 'single_command', confirmation: true, command: cmd

View file

@ -24,13 +24,13 @@ describe SingleCommandController do
end
it 'handles parameterless commands' do
commands = {"home x" => :home_x,
"home y" => :home_y,
"home z" => :home_z,
"home all" => :home_all,
"emergency stop" => :emergency_stop }
commands = { "home x" => :home_x,
"home y" => :home_y,
"home z" => :home_z,
"home all" => :home_all,
"emergency stop" => :emergency_stop }
commands.each do |key, val|
message.payload = {"command" => key}
message.payload = {"action" => key}
controller.call
expect(bot.commands.last).to eq(val => [])
end