fix(log): Don't fail on non-string custom fields

This commit is contained in:
Pixelastic 2018-03-08 16:13:59 +01:00
parent 7783b79e73
commit c42a52abbf
2 changed files with 19 additions and 1 deletions

View File

@ -79,7 +79,7 @@ module Jekyll
# Convert all variables
content = File.open(file).read
metadata.each do |key, value|
content = content.gsub("{#{key}}", value)
content = content.gsub("{#{key}}", value.to_s)
end
# Display each line differently

View File

@ -27,6 +27,24 @@ describe(Jekyll::Algolia::Logger) do
expect(current).to have_received(:log).with('I: Info line my_index')
expect(current).to have_received(:log).with('W: Warning line')
end
context 'with non-string metadata' do
describe do
let(:metadata) { { 'index_name' => false } }
it do
expect(current).to have_received(:log).with('I: Info line false')
end
end
describe do
let(:metadata) { { 'index_name' => %w[foo bar] } }
it do
expect(current)
.to have_received(:log)
.with('I: Info line ["foo", "bar"]')
end
end
end
end
describe '.log' do