1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-03 17:55:52 +03:00

Encodes nested hashes in request body as json

Этот коммит содержится в:
Max Melentiev
2016-02-26 16:23:07 +06:00
родитель d127a52364
Коммит 1b12435d8b
2 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@@ -44,4 +44,23 @@ RSpec.describe Telegram::Bot::Client do
end
end
end
describe '.prepare_body' do
subject { described_class.prepare_body(input) }
context 'when plain hash is given' do
let(:input) { {a: 1, b: '2', c: [1, 2]} }
it { should eq input }
end
context 'when nested hash is given' do
let(:input) { {a: 1, b: '2', c: [1, 2], d: {a: 1}, e: {b: []}} }
it 'encodes nested hashes to json' do
expected = input.dup
%i(d e).each { |x| expected[x] = expected[x].to_json }
should eq expected
end
end
end
end