systemd-journal 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  RSpec.describe Systemd::Journal do
4
4
  subject(:j) do
@@ -8,8 +8,8 @@ RSpec.describe Systemd::Journal do
8
8
  end
9
9
  end
10
10
 
11
- describe 'open' do
12
- it 'creates and closes' do
11
+ describe "open" do
12
+ it "creates and closes" do
13
13
  expect(Systemd::Journal::Native).to receive(:sd_journal_close)
14
14
  .and_call_original
15
15
 
@@ -17,7 +17,7 @@ RSpec.describe Systemd::Journal do
17
17
  expect(result).to eq 1
18
18
  end
19
19
 
20
- it 'raises original exception when creating journal fails' do
20
+ it "raises original exception when creating journal fails" do
21
21
  expect(Systemd::Journal::Native).to_not receive(:sd_journal_close)
22
22
 
23
23
  expect do
@@ -26,32 +26,80 @@ RSpec.describe Systemd::Journal do
26
26
  end
27
27
  end
28
28
 
29
- describe 'initialize' do
29
+ describe "initialize" do
30
30
  subject(:j) { Systemd::Journal }
31
31
 
32
- it 'detects invalid argument combinations' do
33
- expect { j.new(path: '/', files: []) }.to raise_error(ArgumentError)
34
- expect { j.new(container: '', files: []) }.to raise_error(ArgumentError)
35
- expect { j.new(container: '', path: '/') }.to raise_error(ArgumentError)
32
+ it "detects invalid argument combinations" do
33
+ expect { j.new(path: "/", files: []) }.to raise_error(ArgumentError)
34
+ expect { j.new(container: "", files: []) }.to raise_error(ArgumentError)
35
+ expect { j.new(container: "", path: "/") }.to raise_error(ArgumentError)
36
36
  end
37
37
 
38
- it 'raises ArgumentError on attempt to open a container without support' do
38
+ it "raises ArgumentError on attempt to open a container without support" do
39
39
  allow(Systemd::Journal::Native).to receive(:open_container?)
40
40
  .and_return(false)
41
41
 
42
- expect { j.new(container: 'test') }.to raise_error(ArgumentError)
42
+ expect { j.new(container: "test") }.to raise_error(ArgumentError)
43
+ end
44
+
45
+ context "auto_reopen" do
46
+ it "returns nil as default behavior" do
47
+ journal = Systemd::Journal.new
48
+ expect(journal.auto_reopen).to be_falsy
49
+ end
50
+
51
+ it "returns default iterations with true" do
52
+ journal = Systemd::Journal.new(auto_reopen: true)
53
+ expect(journal.auto_reopen).to be_truthy
54
+ end
55
+
56
+ it "returns nil with false" do
57
+ journal = Systemd::Journal.new(auto_reopen: false)
58
+ expect(journal.auto_reopen).to be_falsy
59
+ end
60
+
61
+ it "returns iterations with custom value" do
62
+ journal = Systemd::Journal.new(auto_reopen: 12345)
63
+ expect(journal.auto_reopen).to be 12345
64
+ end
65
+
66
+ it "should re-open internal journal pointer at specified iterations" do
67
+ journal = Systemd::Journal.new(file: journal_file, auto_reopen: 2)
68
+ journal.seek(:head)
69
+
70
+ journal.add_filters({syslog_identifier: "kernel"})
71
+ journal.add_conjunction
72
+ journal.add_filters({priority: "6"})
73
+ journal.add_disjunction
74
+ journal.add_filters({_transport: "kernel"})
75
+
76
+ internal_journal = journal.instance_variable_get(:@ptr)
77
+
78
+ journal.move_next
79
+ expect(journal.instance_variable_get(:@ptr)).to be internal_journal
80
+
81
+ journal.move_next
82
+ expect(journal.instance_variable_get(:@ptr)).to_not be internal_journal
83
+ expect(journal.instance_variable_get(:@reopen_filter_conditions)).to eq [
84
+ {syslog_identifier: "kernel"},
85
+ :conjunction,
86
+ {priority: "6"},
87
+ :disjunction,
88
+ {_transport: "kernel"}
89
+ ]
90
+ end
43
91
  end
44
92
  end
45
93
 
46
- describe 'close' do
47
- it 'closes the underlying file' do
94
+ describe "close" do
95
+ it "closes the underlying file" do
48
96
  expect(Systemd::Journal::Native).to receive(:sd_journal_close)
49
97
  .and_call_original
50
98
 
51
99
  j.close
52
100
  end
53
101
 
54
- it 'unregisters the finalizer' do
102
+ it "unregisters the finalizer" do
55
103
  expect(ObjectSpace).to receive(:undefine_finalizer)
56
104
  .with(j)
57
105
  .and_call_original
@@ -59,53 +107,53 @@ RSpec.describe Systemd::Journal do
59
107
  j.close
60
108
  end
61
109
 
62
- it 'does not fail if called more than once' do
110
+ it "does not fail if called more than once" do
63
111
  j.close
64
112
  expect { j.close }.to_not raise_error
65
113
  end
66
114
 
67
- it 'marks the journal as closed' do
115
+ it "marks the journal as closed" do
68
116
  expect(j).to_not be_closed
69
117
  j.close
70
118
  expect(j).to be_closed
71
119
  end
72
120
  end
73
121
 
74
- describe 'query_unique' do
75
- it 'throws a JournalError on invalid return code' do
122
+ describe "query_unique" do
123
+ it "throws a JournalError on invalid return code" do
76
124
  expect(Systemd::Journal::Native).to receive(:sd_journal_enumerate_unique)
77
125
  .and_return(-1)
78
126
 
79
127
  expect { j.query_unique(:_pid) }.to raise_error(Systemd::JournalError)
80
128
  end
81
129
 
82
- it 'lists all the unique values for the given field' do
83
- values = j.query_unique(:_transport)
84
- transports = %w(syslog journal stdout kernel driver)
130
+ it "lists all the unique values for the given field" do
131
+ values = j.query_unique(:_transport)
132
+ transports = %w[syslog journal stdout kernel driver]
85
133
 
86
134
  expect(values.length).to eq(5)
87
135
  expect(values).to include(*transports)
88
136
  end
89
137
  end
90
138
 
91
- describe 'disk_usage' do
92
- it 'throws a JournalError on invalid return code' do
139
+ describe "disk_usage" do
140
+ it "throws a JournalError on invalid return code" do
93
141
  expect(Systemd::Journal::Native).to receive(:sd_journal_get_usage)
94
142
  .and_return(-1)
95
143
 
96
144
  expect { j.disk_usage }.to raise_error(Systemd::JournalError)
97
145
  end
98
146
 
99
- it 'returns the disk usage of the example journal file' do
100
- pending 'blocks? bytes?'
147
+ it "returns the disk usage of the example journal file" do
148
+ pending "blocks? bytes?"
101
149
  expect(j.disk_usage).to eq(4_005_888)
102
150
  # force failure to make travis-ci happy
103
151
  expect(true).to be false
104
152
  end
105
153
  end
106
154
 
107
- describe 'data_threshold' do
108
- it 'throws a JournalError on invalid return code' do
155
+ describe "data_threshold" do
156
+ it "throws a JournalError on invalid return code" do
109
157
  expect(Systemd::Journal::Native)
110
158
  .to receive(:sd_journal_get_data_threshold)
111
159
  .and_return(-1)
@@ -113,13 +161,13 @@ RSpec.describe Systemd::Journal do
113
161
  expect { j.data_threshold }.to raise_error(Systemd::JournalError)
114
162
  end
115
163
 
116
- it 'returns the default 64K' do
164
+ it "returns the default 64K" do
117
165
  expect(j.data_threshold).to eq(0x0010000)
118
166
  end
119
167
  end
120
168
 
121
- describe 'data_threshold=' do
122
- it 'throws a JournalError on invalid return code' do
169
+ describe "data_threshold=" do
170
+ it "throws a JournalError on invalid return code" do
123
171
  expect(Systemd::Journal::Native)
124
172
  .to receive(:sd_journal_set_data_threshold)
125
173
  .and_return(-1)
@@ -128,62 +176,62 @@ RSpec.describe Systemd::Journal do
128
176
  end
129
177
  end
130
178
 
131
- describe 'read_field' do
132
- it 'throws a JournalError on invalid return code' do
179
+ describe "read_field" do
180
+ it "throws a JournalError on invalid return code" do
133
181
  expect(Systemd::Journal::Native).to receive(:sd_journal_get_data)
134
182
  .and_return(-1)
135
183
 
136
184
  expect { j.read_field(:message) }.to raise_error(Systemd::JournalError)
137
185
  end
138
186
 
139
- it 'returns the correct value' do
140
- expect(j.read_field(:_hostname)).to eq('arch')
187
+ it "returns the correct value" do
188
+ expect(j.read_field(:_hostname)).to eq("arch")
141
189
  end
142
190
  end
143
191
 
144
- describe 'current_entry' do
145
- it 'throws a JournalError on invalid return code' do
192
+ describe "current_entry" do
193
+ it "throws a JournalError on invalid return code" do
146
194
  expect(Systemd::Journal::Native).to receive(:sd_journal_enumerate_data)
147
195
  .and_return(-1)
148
196
 
149
197
  expect { j.current_entry }.to raise_error(Systemd::JournalError)
150
198
  end
151
199
 
152
- it 'returns a JournalEntry with the correct values' do
200
+ it "returns a JournalEntry with the correct values" do
153
201
  entry = j.current_entry
154
- expect(entry._hostname).to eq('arch')
155
- expect(entry.message).to start_with('Allowing runtime journal')
202
+ expect(entry._hostname).to eq("arch")
203
+ expect(entry.message).to start_with("Allowing runtime journal")
156
204
  end
157
205
  end
158
206
 
159
- describe 'each' do
160
- it 'returns an enumerator' do
207
+ describe "each" do
208
+ it "returns an enumerator" do
161
209
  expect(j.each.class).to be Enumerator
162
210
  end
163
211
 
164
- it 'throws a JournalError on invalid return code' do
212
+ it "throws a JournalError on invalid return code" do
165
213
  expect(Systemd::Journal::Native).to receive(:sd_journal_seek_head)
166
214
  .and_return(-1)
167
215
 
168
216
  expect { j.each }.to raise_error(Systemd::JournalError)
169
217
  end
170
218
 
171
- it 'properly enumerates all the entries' do
219
+ it "properly enumerates all the entries" do
172
220
  entries = j.each.map(&:message)
173
221
 
174
- expect(entries.first).to start_with('Allowing runtime journal')
175
- expect(entries.last).to start_with('ROOT LOGIN ON tty1')
222
+ expect(entries.first).to start_with("Allowing runtime journal")
223
+ expect(entries.last).to start_with("ROOT LOGIN ON tty1")
176
224
  end
177
225
  end
178
226
 
179
- context 'with catalog messages' do
180
- let(:msg_id) { 'f77379a8490b408bbe5f6940505a777b' }
181
- let(:msg_text) { 'Subject: The Journal has been started' }
227
+ context "with catalog messages" do
228
+ let(:msg_id) { "f77379a8490b408bbe5f6940505a777b" }
229
+ let(:msg_text) { "Subject: The Journal has been started" }
182
230
 
183
- describe 'catalog_for' do
231
+ describe "catalog_for" do
184
232
  subject(:j) { Systemd::Journal }
185
233
 
186
- it 'throws a JournalError on invalid return code' do
234
+ it "throws a JournalError on invalid return code" do
187
235
  expect(Systemd::Journal::Native)
188
236
  .to receive(:sd_journal_get_catalog_for_message_id)
189
237
  .and_return(-1)
@@ -191,14 +239,14 @@ RSpec.describe Systemd::Journal do
191
239
  expect { j.catalog_for(msg_id) }.to raise_error(Systemd::JournalError)
192
240
  end
193
241
 
194
- it 'returns the correct catalog entry' do
242
+ it "returns the correct catalog entry" do
195
243
  cat = Systemd::Journal.catalog_for(msg_id)
196
244
  expect(cat.downcase).to start_with(msg_text.downcase)
197
245
  end
198
246
  end
199
247
 
200
- describe 'current_catalog' do
201
- it 'throws a JournalError on invalid return code' do
248
+ describe "current_catalog" do
249
+ it "throws a JournalError on invalid return code" do
202
250
  expect(Systemd::Journal::Native)
203
251
  .to receive(:sd_journal_get_catalog)
204
252
  .and_return(-1)
@@ -206,7 +254,7 @@ RSpec.describe Systemd::Journal do
206
254
  expect { j.current_catalog }.to raise_error(Systemd::JournalError)
207
255
  end
208
256
 
209
- it 'returns the correct catalog entry' do
257
+ it "returns the correct catalog entry" do
210
258
  # find first entry with a catalog
211
259
  j.move_next until j.current_entry.catalog?
212
260
 
@@ -215,64 +263,64 @@ RSpec.describe Systemd::Journal do
215
263
  end
216
264
  end
217
265
 
218
- describe 'filter' do
219
- it 'does basic filtering as expected' do
220
- j.filter(_transport: 'kernel')
266
+ describe "filter" do
267
+ it "does basic filtering as expected" do
268
+ j.filter(_transport: "kernel")
221
269
  j.each do |entry|
222
- expect(entry._transport).to eq('kernel')
270
+ expect(entry._transport).to eq("kernel")
223
271
  end
224
272
  expect(j.count).to eq(435)
225
273
  end
226
274
 
227
- it 'does filtering with AND conditions' do
228
- j.filter(_transport: 'kernel', priority: 3)
275
+ it "does filtering with AND conditions" do
276
+ j.filter(_transport: "kernel", priority: 3)
229
277
  expect(j.count).to eq(2)
230
278
  j.each do |e|
231
- expect(e._transport).to eq('kernel')
232
- expect(e.priority).to eq('3')
279
+ expect(e._transport).to eq("kernel")
280
+ expect(e.priority).to eq("3")
233
281
  end
234
282
  end
235
283
 
236
- it 'does basic filtering with multiple options for the same key' do
237
- j.filter(_transport: %w(kernel driver))
284
+ it "does basic filtering with multiple options for the same key" do
285
+ j.filter(_transport: %w[kernel driver])
238
286
  j.each do |entry|
239
- expect(%w(kernel driver)).to include(entry._transport)
287
+ expect(%w[kernel driver]).to include(entry._transport)
240
288
  end
241
289
  expect(j.count).to eq(438)
242
290
  end
243
291
 
244
- it 'does basic filtering with multiple keys' do
292
+ it "does basic filtering with multiple keys" do
245
293
  j.filter(
246
- { _transport: 'kernel' },
247
- { _systemd_unit: 'systemd-journald.service' }
294
+ {_transport: "kernel"},
295
+ {_systemd_unit: "systemd-journald.service"}
248
296
  )
249
297
 
250
298
  c = j.each_with_object(Hash.new(0)) do |e, h|
251
- h[:transport] += 1 if e._transport == 'kernel'
252
- h[:unit] += 1 if e._systemd_unit == 'systemd-journald.service'
299
+ h[:transport] += 1 if e._transport == "kernel"
300
+ h[:unit] += 1 if e._systemd_unit == "systemd-journald.service"
253
301
  end
254
302
 
255
303
  expect(c[:transport]).to eq(435)
256
304
  expect(c[:unit]).to eq(3)
257
305
  end
258
306
 
259
- it 'does crazy stupid filtering' do
307
+ it "does crazy stupid filtering" do
260
308
  filter = [
261
- { _transport: 'kernel', priority: 4 },
262
- { _systemd_unit: 'getty@tty1.service' },
263
- { _systemd_unit: 'systemd-logind.service', seat_id: 'seat0' },
264
- { priority: [3, 5] }
309
+ {_transport: "kernel", priority: 4},
310
+ {_systemd_unit: "getty@tty1.service"},
311
+ {_systemd_unit: "systemd-logind.service", seat_id: "seat0"},
312
+ {priority: [3, 5]}
265
313
  ]
266
314
 
267
315
  j.filter(*filter)
268
316
 
269
317
  c = j.each_with_object(Hash.new(0)) do |e, h|
270
- h[:a] += 1 if e._transport == 'kernel' && e.priority == '4'
271
- h[:b] += 1 if e._systemd_unit == 'getty@tty1.service'
272
- if e._systemd_unit == 'systemd-logind.service' && e[:seat_id] == 'seat0'
318
+ h[:a] += 1 if e._transport == "kernel" && e.priority == "4"
319
+ h[:b] += 1 if e._systemd_unit == "getty@tty1.service"
320
+ if e._systemd_unit == "systemd-logind.service" && e[:seat_id] == "seat0"
273
321
  h[:c] += 1
274
322
  end
275
- h[:d] += 1 if %w(3 5).include?(e.priority)
323
+ h[:d] += 1 if %w[3 5].include?(e.priority)
276
324
  end
277
325
 
278
326
  # from journalctl --file <fixture> <filter> --output json | wc -l
@@ -283,12 +331,12 @@ RSpec.describe Systemd::Journal do
283
331
  end
284
332
  end
285
333
 
286
- describe 'cursor' do
287
- it 'returns some opaque string' do
334
+ describe "cursor" do
335
+ it "returns some opaque string" do
288
336
  expect(j.cursor).to be_kind_of(String)
289
337
  end
290
338
 
291
- it 'throws an error on failure' do
339
+ it "throws an error on failure" do
292
340
  expect(Systemd::Journal::Native).to receive(:sd_journal_get_cursor)
293
341
  .and_return(-1)
294
342
 
@@ -296,13 +344,13 @@ RSpec.describe Systemd::Journal do
296
344
  end
297
345
  end
298
346
 
299
- describe 'cursor?' do
347
+ describe "cursor?" do
300
348
  let!(:cursor) { j.cursor }
301
- it 'returns true if the cursor matches' do
349
+ it "returns true if the cursor matches" do
302
350
  expect(j.cursor?(cursor)).to be true
303
351
  end
304
352
 
305
- it 'throws an error on failure' do
353
+ it "throws an error on failure" do
306
354
  expect(Systemd::Journal::Native).to receive(:sd_journal_test_cursor)
307
355
  .and_return(-1)
308
356
 
@@ -310,41 +358,41 @@ RSpec.describe Systemd::Journal do
310
358
  end
311
359
  end
312
360
 
313
- describe 'move' do
314
- it 'moves by the specified number of entries' do
361
+ describe "move" do
362
+ it "moves by the specified number of entries" do
315
363
  j.move(1)
316
- expect(j.read_field(:message)).to eq(journal_json[1]['MESSAGE'])
364
+ expect(j.read_field(:message)).to eq(journal_json[1]["MESSAGE"])
317
365
  end
318
366
 
319
- it 'does not move with 0' do
367
+ it "does not move with 0" do
320
368
  j.move(1)
321
369
  j.move(0)
322
- expect(j.read_field(:message)).to eq(journal_json[1]['MESSAGE'])
370
+ expect(j.read_field(:message)).to eq(journal_json[1]["MESSAGE"])
323
371
  end
324
372
 
325
- it 'moves backwards' do
373
+ it "moves backwards" do
326
374
  j.move(3)
327
375
  j.move(-1)
328
- expect(j.read_field(:message)).to eq(journal_json[2]['MESSAGE'])
376
+ expect(j.read_field(:message)).to eq(journal_json[2]["MESSAGE"])
329
377
  end
330
378
 
331
- it 'returns the number of entries moved' do
379
+ it "returns the number of entries moved" do
332
380
  expect(j.move(3)).to eq(3)
333
381
  end
334
382
 
335
- it 'returns the number of entries moved even if if less' do
383
+ it "returns the number of entries moved even if if less" do
336
384
  j.move(2)
337
- expect(j.read_field(:message)).to eq(journal_json[2]['MESSAGE'])
385
+ expect(j.read_field(:message)).to eq(journal_json[2]["MESSAGE"])
338
386
  expect(j.move(-5)).to eq(2)
339
387
  end
340
388
 
341
- it 'returns 0 if it did not move' do
389
+ it "returns 0 if it did not move" do
342
390
  expect(j.move(-1)).to eq(0)
343
391
  end
344
392
  end
345
393
 
346
- describe 'seek' do
347
- it 'treats a string parameter as the cursor' do
394
+ describe "seek" do
395
+ it "treats a string parameter as the cursor" do
348
396
  cursor = j.cursor
349
397
  j.move(3)
350
398
  expect(j.cursor?(cursor)).to be false
@@ -353,36 +401,36 @@ RSpec.describe Systemd::Journal do
353
401
  expect(j.cursor?(cursor)).to be true
354
402
  end
355
403
 
356
- it 'can seek to the end' do
404
+ it "can seek to the end" do
357
405
  j.seek(:tail)
358
406
  j.move_previous
359
407
  expect(j.move_next).to be false
360
408
  end
361
409
 
362
- it 'can seek to the start' do
410
+ it "can seek to the start" do
363
411
  j.seek(:start)
364
412
  j.move_next
365
413
  expect(j.move_previous).to be false
366
414
  end
367
415
 
368
- it 'can seek based on timestamp' do
369
- j.seek(Time.parse('2013-03-28T21:07:21-04:00'))
416
+ it "can seek based on timestamp" do
417
+ j.seek(Time.parse("2013-03-28T21:07:21-04:00"))
370
418
  j.move_next
371
419
 
372
420
  entry = j.current_entry
373
- ts = entry.realtime_timestamp
421
+ ts = entry.realtime_timestamp
374
422
 
375
- expect(entry.message).to start_with('input: ImExPS/2')
376
- expect(ts.utc.iso8601).to eq('2013-03-29T01:07:21Z')
423
+ expect(entry.message).to start_with("input: ImExPS/2")
424
+ expect(ts.utc.iso8601).to eq("2013-03-29T01:07:21Z")
377
425
  end
378
426
 
379
- it 'throws an ArgumentError for other types' do
427
+ it "throws an ArgumentError for other types" do
380
428
  expect { j.seek(5) }.to raise_error(ArgumentError)
381
429
  end
382
430
  end
383
431
 
384
- describe 'wait' do
385
- it 'returns nil if nothing happens' do
432
+ describe "wait" do
433
+ it "returns nil if nothing happens" do
386
434
  expect(Systemd::Journal::Native)
387
435
  .to receive(:sd_journal_wait)
388
436
  .and_return(:nop)
@@ -390,7 +438,7 @@ RSpec.describe Systemd::Journal do
390
438
  expect(j.wait(1)).to be nil
391
439
  end
392
440
 
393
- it 'returns :append if new entries are found' do
441
+ it "returns :append if new entries are found" do
394
442
  expect(Systemd::Journal::Native)
395
443
  .to receive(:sd_journal_wait)
396
444
  .and_return(:append)
@@ -398,7 +446,7 @@ RSpec.describe Systemd::Journal do
398
446
  expect(j.wait(1)).to be :append
399
447
  end
400
448
 
401
- it 'raise a JournalError on error' do
449
+ it "raise a JournalError on error" do
402
450
  expect(Systemd::Journal::Native)
403
451
  .to receive(:sd_journal_wait)
404
452
  .and_return(-1)
@@ -406,46 +454,46 @@ RSpec.describe Systemd::Journal do
406
454
  expect { j.wait(1) }.to raise_error(Systemd::JournalError)
407
455
  end
408
456
 
409
- it 'can use select' do
410
- pending 'not available on JRUBY' if Systemd::Journal::IS_JRUBY
457
+ it "can use select" do
458
+ pending "not available on JRUBY" if Systemd::Journal::IS_JRUBY
411
459
  expect(Systemd::Journal::Native).to_not receive(:sd_journal_wait)
412
460
  j.wait(1, select: true)
413
461
  end
414
462
 
415
- it 'ignores request to use select on JRuby' do
416
- pending 'not necessary on MRI' unless Systemd::Journal::IS_JRUBY
463
+ it "ignores request to use select on JRuby" do
464
+ pending "not necessary on MRI" unless Systemd::Journal::IS_JRUBY
417
465
  expect(Systemd::Journal::Native).to receive(:sd_journal_wait)
418
466
  j.wait(1, select: true)
419
467
  end
420
468
  end
421
469
 
422
- describe 'wait_select_reliable?' do
423
- it 'should not throw an error' do
470
+ describe "wait_select_reliable?" do
471
+ it "should not throw an error" do
424
472
  expect { j.wait_select_reliable? }.to_not raise_error
425
473
  end
426
474
 
427
- it 'should return a boolean' do
475
+ it "should return a boolean" do
428
476
  expect([true, false]).to include(j.wait_select_reliable?)
429
477
  end
430
478
  end
431
479
 
432
- describe 'message' do
433
- it 'escapes percent signs in messages' do
480
+ describe "message" do
481
+ it "escapes percent signs in messages" do
434
482
  expect(Systemd::Journal::Native).to receive(:sd_journal_send)
435
- .with(:string, 'MESSAGE=hello %% world %%', :string, nil)
483
+ .with(:string, "MESSAGE=hello %% world %%", :string, nil)
436
484
  .and_return(0)
437
485
 
438
- Systemd::Journal.message(message: 'hello % world %')
486
+ Systemd::Journal.message(message: "hello % world %")
439
487
  end
440
488
  end
441
489
 
442
- describe 'print' do
443
- it 'escapes percent signs' do
490
+ describe "print" do
491
+ it "escapes percent signs" do
444
492
  expect(Systemd::Journal::Native).to receive(:sd_journal_print)
445
- .with(Systemd::Journal::LOG_DEBUG, 'hello %% world %%')
493
+ .with(Systemd::Journal::LOG_DEBUG, "hello %% world %%")
446
494
  .and_return(0)
447
495
 
448
- Systemd::Journal.print(Systemd::Journal::LOG_DEBUG, 'hello % world %')
496
+ Systemd::Journal.print(Systemd::Journal::LOG_DEBUG, "hello % world %")
449
497
  end
450
498
  end
451
499
  end
data/spec/systemd_spec.rb CHANGED
@@ -1,15 +1,15 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  RSpec.describe Systemd do
4
- describe 'machine_id' do
5
- it 'is an alias for Systemd::Id128.machine_id' do
4
+ describe "machine_id" do
5
+ it "is an alias for Systemd::Id128.machine_id" do
6
6
  expect(Systemd::Id128).to receive(:machine_id)
7
7
  Systemd.machine_id
8
8
  end
9
9
  end
10
10
 
11
- describe 'boot_id' do
12
- it 'is an alias for Systemd::Id128.boot_id' do
11
+ describe "boot_id" do
12
+ it "is an alias for Systemd::Id128.boot_id" do
13
13
  expect(Systemd::Id128).to receive(:boot_id)
14
14
  Systemd.boot_id
15
15
  end