Skip to content

Commit 2a0e62c

Browse files
committed
Patch ruby 3.4 hash inspect syntax
1 parent 0703e5e commit 2a0e62c

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

spec/support/helpers.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ def stub_loga
1818
allow(loga).to receive(:logger).and_return(logger)
1919
loga
2020
end
21+
22+
def with_new_ruby(**data)
23+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4')
24+
data[:test]
25+
else
26+
data[:else]
27+
end
28+
end
2129
end

spec/unit/loga/formatters/gelf_formatter_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@
6666
let(:message) { { message: 'Wooden house' } }
6767

6868
it 'the short_message is a String reprentation of that Hash' do
69-
expect(json['short_message']).to eq('{:message=>"Wooden house"}')
69+
expect(json['short_message']).to eq(
70+
with_new_ruby(
71+
test: '{message: "Wooden house"}',
72+
else: '{:message=>"Wooden house"}',
73+
),
74+
)
7075
end
7176

7277
include_examples 'valid GELF message'

spec/unit/loga/formatters/simple_formatter_spec.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@
3232
let(:message) { { record: 'Wooden house' } }
3333

3434
specify do
35-
expect(subject).to eq("I, #{time_pid} {:record=>\"Wooden house\"}\n")
35+
expect(subject).to eq(
36+
with_new_ruby(
37+
test: "I, #{time_pid} {record: \"Wooden house\"}\n",
38+
else: "I, #{time_pid} {:record=>\"Wooden house\"}\n",
39+
),
40+
)
3641
end
3742
end
3843

@@ -80,7 +85,12 @@
8085
end
8186

8287
specify do
83-
expect(subject).to eq("I, #{time_pid} Hello World data={:admin=>true, :user=>{:email=>\"hello@world.com\"}}\n")
88+
expect(subject).to eq(
89+
with_new_ruby(
90+
test: "I, #{time_pid} Hello World data={admin: true, user: {email: \"hello@world.com\"}}\n",
91+
else: "I, #{time_pid} Hello World data={:admin=>true, :user=>{:email=>\"hello@world.com\"}}\n",
92+
),
93+
)
8494
end
8595
end
8696

@@ -94,7 +104,12 @@
94104
end
95105

96106
specify do
97-
expect(subject).to eq("I, #{time_pid} Hello World type=request data={:ssl=>true}\n")
107+
expect(subject).to eq(
108+
with_new_ruby(
109+
test: "I, #{time_pid} Hello World type=request data={ssl: true}\n",
110+
else: "I, #{time_pid} Hello World type=request data={:ssl=>true}\n",
111+
),
112+
)
98113
end
99114
end
100115
end

0 commit comments

Comments
 (0)