Skip to content

Commit 0e84fbb

Browse files
authored
Merge pull request #4677 from Watson1978/test-hash-inspect
tests: fix Hash#inspect format for Ruby HEAD
2 parents d1a58fd + ab7a81d commit 0e84fbb

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

test/config/test_element.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ def element(name = 'ROOT', arg = '', attrs = {}, elements = [], unused = nil)
282282
dump = <<-CONF
283283
name:ROOT, arg:, {\"k1\"=>\"v1\"}, [name:test, arg:ext, {\"k2\"=>\"v2\"}, []]
284284
CONF
285-
assert_not_equal(e.to_s, e.inspect)
286-
assert_equal(dump.chomp, e.inspect)
285+
assert_not_equal(e.to_s, e.inspect.gsub(' => ', '=>'))
286+
assert_equal(dump.chomp, e.inspect.gsub(' => ', '=>'))
287287
end
288288
end
289289

test/plugin/test_filter_stdout.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ def test_output_type_hash
8686
d = create_driver(CONFIG + config_element("", "", { "output_type" => "hash" }))
8787
etime = event_time("2016-10-07 21:09:31.012345678 UTC")
8888
out = capture_log(d) { filter(d, etime, {'test' => 'test'}) }
89-
assert_equal "2016-10-07 21:09:31.012345678 +0000 filter.test: {\"test\"=>\"test\"}\n", out
89+
assert_equal "2016-10-07 21:09:31.012345678 +0000 filter.test: {\"test\"=>\"test\"}\n", out.gsub(' => ', '=>')
9090

9191
# NOTE: Float::NAN is not jsonable, but hash string can output it.
9292
d = create_driver(CONFIG + config_element("", "", { "output_type" => "hash" }))
9393
out = capture_log(d) { filter(d, etime, {'test' => Float::NAN}) }
94-
assert_equal "2016-10-07 21:09:31.012345678 +0000 filter.test: {\"test\"=>NaN}\n", out
94+
assert_equal "2016-10-07 21:09:31.012345678 +0000 filter.test: {\"test\"=>NaN}\n", out.gsub(' => ', '=>')
9595
end
9696

9797
# Use include_time_key to output the message's time
@@ -172,7 +172,7 @@ def test_hash
172172
d = create_driver(conf)
173173
etime = event_time("2016-10-07 21:09:31.012345678 UTC")
174174
out = capture_log(d) { filter(d, etime, {'test' => 'test'}) }
175-
assert_equal "2016-10-07 21:09:31.012345678 +0000 filter.test: {\"test\"=>\"test\"}\n", out
175+
assert_equal "2016-10-07 21:09:31.012345678 +0000 filter.test: {\"test\"=>\"test\"}\n", out.gsub(' => ', '=>')
176176
end
177177

178178
def test_hash_nan
@@ -182,7 +182,7 @@ def test_hash_nan
182182
d = create_driver(conf)
183183
etime = event_time("2016-10-07 21:09:31.012345678 UTC")
184184
out = capture_log(d) { filter(d, etime, {'test' => Float::NAN}) }
185-
assert_equal "2016-10-07 21:09:31.012345678 +0000 filter.test: {\"test\"=>NaN}\n", out
185+
assert_equal "2016-10-07 21:09:31.012345678 +0000 filter.test: {\"test\"=>NaN}\n", out.gsub(' => ', '=>')
186186
end
187187

188188
# Use include_time_key to output the message's time

test/plugin/test_formatter_hash.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def test_format(data)
2626
d = create_driver({"newline" => newline_conf})
2727
formatted = d.instance.format(tag, @time, record)
2828

29-
assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}#{newline}!, formatted.encode(Encoding::UTF_8))
29+
assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}#{newline}!, formatted.gsub(' => ', '=>').encode(Encoding::UTF_8))
3030
end
3131

3232
def test_format_without_newline
3333
d = create_driver('add_newline' => false)
3434
formatted = d.instance.format(tag, @time, record)
3535

36-
assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}!, formatted.encode(Encoding::UTF_8))
36+
assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}!, formatted.gsub(' => ', '=>').encode(Encoding::UTF_8))
3737
end
3838
end

test/plugin/test_out_stdout.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def create_driver(conf = CONFIG)
9595
d.feed(time, {'test' => 'test2'})
9696
end
9797
end
98-
assert_equal "#{Time.at(time).localtime.strftime(TIME_FORMAT)} test: {\"test\"=>\"test2\"}\n", out
98+
assert_equal "#{Time.at(time).localtime.strftime(TIME_FORMAT)} test: {\"test\"=>\"test2\"}\n", out.gsub(' => ', '=>')
9999

100100
# NOTE: Float::NAN is not jsonable, but hash string can output it.
101101
out = capture_log { d.feed('test', time, {'test' => Float::NAN}) }
102-
assert_equal "#{Time.at(time).localtime.strftime(TIME_FORMAT)} test: {\"test\"=>NaN}\n", out
102+
assert_equal "#{Time.at(time).localtime.strftime(TIME_FORMAT)} test: {\"test\"=>NaN}\n", out.gsub(' => ', '=>')
103103
end
104104
end
105105

@@ -171,7 +171,7 @@ def create_driver(conf = CONFIG)
171171
end
172172
end
173173

174-
assert_equal "#{Time.at(time).localtime.strftime(TIME_FORMAT)} test: {\"test\"=>\"test\"}\n", out
174+
assert_equal "#{Time.at(time).localtime.strftime(TIME_FORMAT)} test: {\"test\"=>\"test\"}\n", out.gsub(' => ', '=>')
175175
end
176176
end
177177
end

0 commit comments

Comments
 (0)