systemd-journal 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,15 +10,15 @@ describe Systemd::Journal do
10
10
  end
11
11
 
12
12
  it 'accepts flags as an argument' do
13
- Systemd::Journal::Native.should_receive(:sd_journal_open).with(anything, 1234)
13
+ Systemd::Journal::Native.should_receive(:sd_journal_open)
14
+ .with(anything, 1234)
15
+
14
16
  Systemd::Journal.new(flags: 1234)
15
17
  end
16
18
 
17
19
  it 'raises a Journal Error if a native call fails' do
18
20
  Systemd::Journal::Native.should_receive(:sd_journal_open).and_return(-1)
19
- expect {
20
- Systemd::Journal.new
21
- }.to raise_error(Systemd::JournalError)
21
+ expect { Systemd::Journal.new }.to raise_error(Systemd::JournalError)
22
22
  end
23
23
  end
24
24
 
@@ -36,44 +36,59 @@ describe Systemd::Journal do
36
36
  end
37
37
  end
38
38
 
39
- ['next', 'previous'].each do |direction|
39
+ %w{next previous}.each do |direction|
40
40
  describe "#move_#{direction}" do
41
41
  it 'returns true on a successful move' do
42
42
  j = Systemd::Journal.new
43
- Systemd::Journal::Native.should_receive(:"sd_journal_#{direction}").and_return(1)
43
+ Systemd::Journal::Native
44
+ .should_receive(:"sd_journal_#{direction}")
45
+ .and_return(1)
46
+
44
47
  j.send(:"move_#{direction}").should eq(true)
45
48
  end
46
49
 
47
50
  it 'returns false on EOF' do
48
51
  j = Systemd::Journal.new
49
- Systemd::Journal::Native.should_receive(:"sd_journal_#{direction}").and_return(0)
52
+ Systemd::Journal::Native
53
+ .should_receive(:"sd_journal_#{direction}")
54
+ .and_return(0)
55
+
50
56
  j.send(:"move_#{direction}").should eq(false)
51
57
  end
52
58
 
53
59
  it 'raises an exception on failure' do
54
60
  j = Systemd::Journal.new
55
- Systemd::Journal::Native.should_receive(:"sd_journal_#{direction}").and_return(-1)
56
- expect {
61
+ Systemd::Journal::Native
62
+ .should_receive(:"sd_journal_#{direction}")
63
+ .and_return(-1)
64
+
65
+ expect do
57
66
  j.send(:"move_#{direction}")
58
- }.to raise_error(Systemd::JournalError)
67
+ end.to raise_error(Systemd::JournalError)
59
68
  end
60
69
  end
61
70
 
62
71
  describe "#move_#{direction}_skip" do
63
72
  it 'returns the number of records moved by' do
64
- Systemd::Journal::Native.should_receive(:"sd_journal_#{direction}_skip").
65
- with(anything, 10).and_return(10)
73
+ Systemd::Journal::Native
74
+ .should_receive(:"sd_journal_#{direction}_skip")
75
+ .with(anything, 10)
76
+ .and_return(10)
66
77
 
67
78
  Systemd::Journal.new.send(:"move_#{direction}_skip", 10).should eq(10)
68
79
  end
69
80
 
70
81
  it 'raises an exception on failure' do
71
- Systemd::Journal::Native.should_receive(:"sd_journal_#{direction}_skip").
72
- with(anything, 10).and_return(-1)
82
+ Systemd::Journal::Native
83
+ .should_receive(:"sd_journal_#{direction}_skip")
84
+ .with(anything, 10)
85
+ .and_return(-1)
73
86
 
74
87
  j = Systemd::Journal.new
75
88
 
76
- expect { j.send(:"move_#{direction}_skip", 10) }.to raise_error(Systemd::JournalError)
89
+ expect do
90
+ j.send(:"move_#{direction}_skip", 10)
91
+ end.to raise_error(Systemd::JournalError)
77
92
  end
78
93
  end
79
94
  end
@@ -83,7 +98,7 @@ describe Systemd::Journal do
83
98
  j = Systemd::Journal.new
84
99
  j.should_receive(:seek).with(:head).and_return(0)
85
100
  j.stub(:move_next).and_return(nil)
86
- j.each{|e| nil }
101
+ j.each { |e| nil }
87
102
  end
88
103
 
89
104
  it 'should return an enumerator if no block is given' do
@@ -92,7 +107,7 @@ describe Systemd::Journal do
92
107
  end
93
108
 
94
109
  it 'should return each entry in the journal' do
95
- entries = [{'_PID' => 1}, {'_PID' => 2}]
110
+ entries = [{ '_PID' => 1 }, { '_PID' => 2 }]
96
111
  entry = nil
97
112
 
98
113
  j = Systemd::Journal.new
@@ -100,7 +115,7 @@ describe Systemd::Journal do
100
115
  j.stub(:current_entry) { entry }
101
116
  j.stub(:move_next) { entry = entries.shift }
102
117
 
103
- j.map{|e| e['_PID'] }.should eq([1, 2])
118
+ j.map { |e| e['_PID'] }.should eq([1, 2])
104
119
  end
105
120
 
106
121
  end
@@ -108,29 +123,40 @@ describe Systemd::Journal do
108
123
  describe '#seek' do
109
124
  it 'moves to the first entry of the file' do
110
125
  j = Systemd::Journal.new
111
- Systemd::Journal::Native.should_receive(:sd_journal_seek_head).and_return(0)
126
+ Systemd::Journal::Native
127
+ .should_receive(:sd_journal_seek_head)
128
+ .and_return(0)
129
+
112
130
  j.seek(:head).should eq(true)
113
131
  end
114
132
 
115
133
  it 'moves to the last entry of the file' do
116
134
  j = Systemd::Journal.new
117
- Systemd::Journal::Native.should_receive(:sd_journal_seek_tail).and_return(0)
135
+ Systemd::Journal::Native
136
+ .should_receive(:sd_journal_seek_tail)
137
+ .and_return(0)
138
+
118
139
  j.seek(:tail).should eq(true)
119
140
  end
120
141
 
121
142
  it 'seeks based on time when a time is provided' do
122
143
  j = Systemd::Journal.new
123
- Systemd::Journal::Native.should_receive(:sd_journal_seek_realtime_usec).and_return(0)
144
+ Systemd::Journal::Native
145
+ .should_receive(:sd_journal_seek_realtime_usec)
146
+ .and_return(0)
147
+
124
148
  j.seek(Time.now).should eq(true)
125
149
  end
126
150
 
127
151
  it 'seeks based on a cursor when a string is provided' do
128
152
  j = Systemd::Journal.new
129
153
 
130
- Systemd::Journal::Native.should_receive(:sd_journal_seek_cursor).
131
- with(anything, "123").and_return(0)
154
+ Systemd::Journal::Native
155
+ .should_receive(:sd_journal_seek_cursor)
156
+ .with(anything, '123')
157
+ .and_return(0)
132
158
 
133
- j.seek("123")
159
+ j.seek('123')
134
160
  end
135
161
 
136
162
  it 'throws an exception if it doesnt understand the type' do
@@ -141,34 +167,41 @@ describe Systemd::Journal do
141
167
 
142
168
  describe '#read_field' do
143
169
  it 'raises an exception if the call fails' do
144
- Systemd::Journal::Native.should_receive(:sd_journal_get_data).and_return(-1)
145
-
146
170
  j = Systemd::Journal.new
147
- expect{ j.read_field(:message) }.to raise_error(Systemd::JournalError)
171
+ Systemd::Journal::Native
172
+ .should_receive(:sd_journal_get_data)
173
+ .and_return(-1)
174
+
175
+ expect { j.read_field(:message) }.to raise_error(Systemd::JournalError)
148
176
  end
149
177
 
150
178
  it 'parses the returned value correctly.' do
151
179
  j = Systemd::Journal.new
180
+ Systemd::Journal::Native
181
+ .should_receive(:sd_journal_get_data) do |ptr, field, out_ptr, len_ptr|
182
+ dummy = 'MESSAGE=hello world'
183
+ out_ptr.write_pointer(FFI::MemoryPointer.from_string(dummy))
184
+ len_ptr.write_size_t(dummy.size)
185
+ 0
186
+ end
152
187
 
153
- Systemd::Journal::Native.should_receive(:sd_journal_get_data) do |ptr, field, out_ptr, len_ptr|
154
- dummy = "MESSAGE=hello world"
155
- out_ptr.write_pointer(FFI::MemoryPointer.from_string(dummy))
156
- len_ptr.write_size_t(dummy.size)
157
- 0
158
- end
159
-
160
- j.read_field(:message).should eq("hello world")
188
+ j.read_field(:message).should eq('hello world')
161
189
  end
162
190
  end
163
191
 
164
192
  describe '#current_entry' do
165
193
  before(:each) do
166
- Systemd::Journal::Native.should_receive(:sd_journal_restart_data).and_return(nil)
194
+ Systemd::Journal::Native
195
+ .should_receive(:sd_journal_restart_data)
196
+ .and_return(nil)
167
197
  end
168
198
 
169
199
  it 'raises an exception if the call fails' do
170
200
  j = Systemd::Journal.new
171
- Systemd::Journal::Native.should_receive(:sd_journal_enumerate_data).and_return(-1)
201
+ Systemd::Journal::Native
202
+ .should_receive(:sd_journal_enumerate_data)
203
+ .and_return(-1)
204
+
172
205
  expect { j.current_entry }.to raise_error(Systemd::JournalError)
173
206
  end
174
207
 
@@ -176,40 +209,52 @@ describe Systemd::Journal do
176
209
  j = Systemd::Journal.new
177
210
  results = ['_PID=100', 'MESSAGE=hello world']
178
211
 
179
- Systemd::Journal::Native.should_receive(:sd_journal_enumerate_data).exactly(3).times do |ptr, out_ptr, len_ptr|
180
- if results.any?
181
- x = results.shift
182
- out_ptr.write_pointer(FFI::MemoryPointer.from_string(x))
183
- len_ptr.write_size_t(x.length)
184
- 1
185
- else
186
- 0
212
+ Systemd::Journal::Native
213
+ .should_receive(:sd_journal_enumerate_data)
214
+ .exactly(3).times do |ptr, out_ptr, len_ptr|
215
+ if results.any?
216
+ x = results.shift
217
+ out_ptr.write_pointer(FFI::MemoryPointer.from_string(x))
218
+ len_ptr.write_size_t(x.length)
219
+ 1
220
+ else
221
+ 0
222
+ end
187
223
  end
188
- end
189
224
 
190
225
  entry = j.current_entry
191
226
 
192
227
  entry._pid.should eq('100')
193
228
  entry.message.should eq('hello world')
194
-
195
229
  end
196
230
  end
197
231
 
198
232
  describe '#query_unique' do
199
233
  before(:each) do
200
- Systemd::Journal::Native.should_receive(:sd_journal_restart_unique).and_return(nil)
234
+ Systemd::Journal::Native
235
+ .should_receive(:sd_journal_restart_unique)
236
+ .and_return(nil)
201
237
  end
202
238
 
203
239
  it 'raises an exception if the call fails' do
204
240
  j = Systemd::Journal.new
205
- Systemd::Journal::Native.should_receive(:sd_journal_query_unique).and_return(-1)
241
+ Systemd::Journal::Native
242
+ .should_receive(:sd_journal_query_unique)
243
+ .and_return(-1)
244
+
206
245
  expect { j.query_unique(:_pid) }.to raise_error(Systemd::JournalError)
207
246
  end
208
247
 
209
248
  it 'raises an exception if the call fails (2)' do
210
249
  j = Systemd::Journal.new
211
- Systemd::Journal::Native.should_receive(:sd_journal_query_unique).and_return(0)
212
- Systemd::Journal::Native.should_receive(:sd_journal_enumerate_unique).and_return(-1)
250
+ Systemd::Journal::Native
251
+ .should_receive(:sd_journal_query_unique)
252
+ .and_return(0)
253
+
254
+ Systemd::Journal::Native
255
+ .should_receive(:sd_journal_enumerate_unique)
256
+ .and_return(-1)
257
+
213
258
  expect { j.query_unique(:_pid) }.to raise_error(Systemd::JournalError)
214
259
  end
215
260
 
@@ -217,20 +262,24 @@ describe Systemd::Journal do
217
262
  j = Systemd::Journal.new
218
263
  results = ['_PID=100', '_PID=200', '_PID=300']
219
264
 
220
- Systemd::Journal::Native.should_receive(:sd_journal_query_unique).and_return(0)
221
-
222
- Systemd::Journal::Native.should_receive(:sd_journal_enumerate_unique).exactly(4).times do |ptr, out_ptr, len_ptr|
223
- if results.any?
224
- x = results.shift
225
- out_ptr.write_pointer(FFI::MemoryPointer.from_string(x))
226
- len_ptr.write_size_t(x.length)
227
- 1
228
- else
229
- 0
265
+ Systemd::Journal::Native
266
+ .should_receive(:sd_journal_query_unique)
267
+ .and_return(0)
268
+
269
+ Systemd::Journal::Native
270
+ .should_receive(:sd_journal_enumerate_unique)
271
+ .exactly(4).times do |ptr, out_ptr, len_ptr|
272
+ if results.any?
273
+ x = results.shift
274
+ out_ptr.write_pointer(FFI::MemoryPointer.from_string(x))
275
+ len_ptr.write_size_t(x.length)
276
+ 1
277
+ else
278
+ 0
279
+ end
230
280
  end
231
- end
232
281
 
233
- j.query_unique(:_pid).should eq(['100', '200', '300'])
282
+ j.query_unique(:_pid).should eq(%w{100 200 300})
234
283
  end
235
284
 
236
285
  end
@@ -240,36 +289,47 @@ describe Systemd::Journal do
240
289
  Systemd::Journal::Native.should_receive(:sd_journal_wait).and_return(-1)
241
290
 
242
291
  j = Systemd::Journal.new
243
- expect{ j.wait(100) }.to raise_error(Systemd::JournalError)
292
+ expect { j.wait(100) }.to raise_error(Systemd::JournalError)
244
293
  end
245
294
 
246
295
  it 'returns the reason we were woken up' do
247
296
  j = Systemd::Journal.new
248
- Systemd::Journal::Native.should_receive(:sd_journal_wait).and_return(:append)
297
+ Systemd::Journal::Native
298
+ .should_receive(:sd_journal_wait)
299
+ .and_return(:append)
300
+
249
301
  j.wait(100).should eq(:append)
250
302
  end
251
303
 
252
304
  it 'returns nil if we reached the timeout.' do
253
305
  j = Systemd::Journal.new
254
- Systemd::Journal::Native.should_receive(:sd_journal_wait).and_return(:nop)
306
+ Systemd::Journal::Native
307
+ .should_receive(:sd_journal_wait)
308
+ .and_return(:nop)
309
+
255
310
  j.wait(100).should eq(nil)
256
311
  end
257
312
  end
258
313
 
259
314
  describe '#add_filter' do
260
315
  it 'raises an exception if the call fails' do
261
- Systemd::Journal::Native.should_receive(:sd_journal_add_match).and_return(-1)
262
-
263
316
  j = Systemd::Journal.new
264
- expect{ j.add_filter(:message, "test") }.to raise_error(Systemd::JournalError)
317
+ Systemd::Journal::Native
318
+ .should_receive(:sd_journal_add_match)
319
+ .and_return(-1)
320
+
321
+ expect do
322
+ j.add_filter(:message, 'test')
323
+ end.to raise_error(Systemd::JournalError)
265
324
  end
266
325
 
267
326
  it 'formats the arguments appropriately' do
268
- Systemd::Journal::Native.should_receive(:sd_journal_add_match).
269
- with(anything, "MESSAGE=test", "MESSAGE=test".length).
270
- and_return(0)
327
+ Systemd::Journal::Native
328
+ .should_receive(:sd_journal_add_match)
329
+ .with(anything, 'MESSAGE=test', 'MESSAGE=test'.length)
330
+ .and_return(0)
271
331
 
272
- Systemd::Journal.new.add_filter(:message, "test")
332
+ Systemd::Journal.new.add_filter(:message, 'test')
273
333
  end
274
334
  end
275
335
 
@@ -288,7 +348,7 @@ describe Systemd::Journal do
288
348
  j.should_receive(:add_filter).with(:priority, 2)
289
349
  j.should_receive(:add_filter).with(:priority, 3)
290
350
 
291
- j.add_filters(priority: [1,2,3])
351
+ j.add_filters(priority: [1, 2, 3])
292
352
  end
293
353
  end
294
354
 
@@ -308,50 +368,62 @@ describe Systemd::Journal do
308
368
  j.should_receive(:add_disjunction).ordered
309
369
  j.should_receive(:add_filter).with(:message, 'hello').ordered
310
370
 
311
- j.filter({priority: 1}, {message: 'hello'})
371
+ j.filter({ priority: 1 }, { message: 'hello' })
312
372
 
313
373
  end
314
374
  end
315
375
 
316
376
  describe '#add_conjunction' do
317
377
  it 'raises an exception if the call fails' do
318
- Systemd::Journal::Native.should_receive(:sd_journal_add_conjunction).and_return(-1)
319
-
320
378
  j = Systemd::Journal.new
321
- expect{ j.add_conjunction }.to raise_error(Systemd::JournalError)
379
+ Systemd::Journal::Native
380
+ .should_receive(:sd_journal_add_conjunction)
381
+ .and_return(-1)
382
+
383
+ expect { j.add_conjunction }.to raise_error(Systemd::JournalError)
322
384
  end
323
385
  end
324
386
 
325
387
  describe '#add_disjunction' do
326
388
  it 'raises an exception if the call fails' do
327
- Systemd::Journal::Native.should_receive(:sd_journal_add_disjunction).and_return(-1)
328
-
329
389
  j = Systemd::Journal.new
330
- expect{ j.add_disjunction }.to raise_error(Systemd::JournalError)
390
+ Systemd::Journal::Native
391
+ .should_receive(:sd_journal_add_disjunction)
392
+ .and_return(-1)
393
+
394
+ expect { j.add_disjunction }.to raise_error(Systemd::JournalError)
331
395
  end
332
396
  end
333
397
 
334
398
  describe '#clear_filters' do
335
399
  it 'flushes the matches' do
336
400
  j = Systemd::Journal.new
337
- Systemd::Journal::Native.should_receive(:sd_journal_flush_matches).and_return(nil)
401
+ Systemd::Journal::Native
402
+ .should_receive(:sd_journal_flush_matches)
403
+ .and_return(nil)
404
+
338
405
  j.clear_filters
339
406
  end
340
407
  end
341
408
 
342
409
  describe '#disk_usage' do
343
410
  it 'returns the size used on disk' do
344
- Systemd::Journal::Native.should_receive(:sd_journal_get_usage) do |ptr, size_ptr|
345
- size_ptr.write_size_t(12)
346
- 0
347
- end
348
411
  j = Systemd::Journal.new
412
+ Systemd::Journal::Native
413
+ .should_receive(:sd_journal_get_usage) do |ptr, size_ptr|
414
+ size_ptr.write_size_t(12)
415
+ 0
416
+ end
417
+
349
418
  j.disk_usage.should eq(12)
350
419
  end
351
420
 
352
421
  it 'raises an error if the call fails' do
353
- Systemd::Journal::Native.should_receive(:sd_journal_get_usage).and_return(-1)
354
422
  j = Systemd::Journal.new
423
+ Systemd::Journal::Native
424
+ .should_receive(:sd_journal_get_usage)
425
+ .and_return(-1)
426
+
355
427
  expect { j.disk_usage }.to raise_error(Systemd::JournalError)
356
428
  end
357
429
  end
@@ -359,41 +431,46 @@ describe Systemd::Journal do
359
431
  describe '#data_threshold=' do
360
432
  it 'sets the data threshold' do
361
433
  j = Systemd::Journal.new
362
-
363
- Systemd::Journal::Native.should_receive(:sd_journal_set_data_threshold).
364
- with(anything, 0x1234).and_return(0)
434
+ Systemd::Journal::Native
435
+ .should_receive(:sd_journal_set_data_threshold)
436
+ .with(anything, 0x1234)
437
+ .and_return(0)
365
438
 
366
439
  j.data_threshold = 0x1234
367
440
  end
368
441
 
369
442
  it 'raises a JournalError on failure' do
370
443
  j = Systemd::Journal.new
444
+ Systemd::Journal::Native
445
+ .should_receive(:sd_journal_set_data_threshold)
446
+ .with(anything, 0x1234)
447
+ .and_return(-1)
371
448
 
372
- Systemd::Journal::Native.should_receive(:sd_journal_set_data_threshold).
373
- with(anything, 0x1234).and_return(-1)
374
-
375
- expect { j.data_threshold = 0x1234 }.to raise_error(Systemd::JournalError)
449
+ expect do
450
+ j.data_threshold = 0x1234
451
+ end.to raise_error(Systemd::JournalError)
376
452
  end
377
453
  end
378
454
 
379
455
  describe '#data_threshold' do
380
456
  it 'gets the data threshold' do
381
457
  j = Systemd::Journal.new
458
+ Systemd::Journal::Native
459
+ .should_receive(:sd_journal_get_data_threshold) do |ptr, size_ptr|
460
+ size_ptr.write_size_t(0x1234)
461
+ 0
462
+ end
382
463
 
383
- Systemd::Journal::Native.should_receive(:sd_journal_get_data_threshold) do |ptr, size_ptr|
384
- size_ptr.write_size_t(0x1234)
385
- 0
386
- end
387
464
  j.data_threshold.should eq(0x1234)
388
465
  end
389
466
 
390
467
  it 'raises a JournalError on failure' do
391
468
  j = Systemd::Journal.new
469
+ Systemd::Journal::Native
470
+ .should_receive(:sd_journal_get_data_threshold)
471
+ .and_return(-3)
392
472
 
393
- Systemd::Journal::Native.should_receive(:sd_journal_get_data_threshold).
394
- and_return(-3)
395
-
396
- expect{ j.data_threshold }.to raise_error(Systemd::JournalError)
473
+ expect { j.data_threshold }.to raise_error(Systemd::JournalError)
397
474
  end
398
475
 
399
476
  end
@@ -401,27 +478,30 @@ describe Systemd::Journal do
401
478
  describe '#cursor?' do
402
479
  it 'returns true if the current cursor is the provided value' do
403
480
  j = Systemd::Journal.new
404
- Systemd::Journal::Native.should_receive(:sd_journal_test_cursor).
405
- with(anything, "1234").and_return(1)
481
+ Systemd::Journal::Native
482
+ .should_receive(:sd_journal_test_cursor)
483
+ .with(anything, '1234').and_return(1)
406
484
 
407
- j.cursor?("1234").should eq(true)
485
+ j.cursor?('1234').should eq(true)
408
486
  end
409
487
 
410
488
  it 'returns false otherwise' do
411
489
  j = Systemd::Journal.new
412
- Systemd::Journal::Native.should_receive(:sd_journal_test_cursor).
413
- with(anything, "1234").and_return(0)
490
+ Systemd::Journal::Native
491
+ .should_receive(:sd_journal_test_cursor)
492
+ .with(anything, '1234')
493
+ .and_return(0)
414
494
 
415
- j.cursor?("1234").should eq(false)
495
+ j.cursor?('1234').should eq(false)
416
496
  end
417
497
 
418
498
  it 'raises a JournalError on failure' do
419
499
  j = Systemd::Journal.new
500
+ Systemd::Journal::Native
501
+ .should_receive(:sd_journal_test_cursor)
502
+ .and_return(-3)
420
503
 
421
- Systemd::Journal::Native.should_receive(:sd_journal_test_cursor).
422
- and_return(-3)
423
-
424
- expect{ j.cursor?('123') }.to raise_error(Systemd::JournalError)
504
+ expect { j.cursor?('123') }.to raise_error(Systemd::JournalError)
425
505
  end
426
506
 
427
507
  end
@@ -429,26 +509,27 @@ describe Systemd::Journal do
429
509
  describe '#cursor' do
430
510
  it 'returns the current cursor' do
431
511
  j = Systemd::Journal.new
512
+ Systemd::Journal::Native
513
+ .should_receive(:sd_journal_get_cursor) do |ptr, out_ptr|
514
+ # this memory will be manually freed. not setting autorelease to
515
+ # false would cause a double free.
516
+ str = FFI::MemoryPointer.from_string('5678')
517
+ str.autorelease = false
432
518
 
433
- Systemd::Journal::Native.should_receive(:sd_journal_get_cursor) do |ptr, out_ptr|
434
- # this memory will be manually freed. not setting autorelease to false
435
- # would cause a double free.
436
- str = FFI::MemoryPointer.from_string("5678")
437
- str.autorelease = false
519
+ out_ptr.write_pointer(str)
520
+ 0
521
+ end
438
522
 
439
- out_ptr.write_pointer(str)
440
- 0
441
- end
442
- j.cursor.should eq("5678")
523
+ j.cursor.should eq('5678')
443
524
  end
444
525
 
445
526
  it 'raises a JournalError on failure' do
446
527
  j = Systemd::Journal.new
528
+ Systemd::Journal::Native
529
+ .should_receive(:sd_journal_get_cursor)
530
+ .and_return(-3)
447
531
 
448
- Systemd::Journal::Native.should_receive(:sd_journal_get_cursor).
449
- and_return(-3)
450
-
451
- expect{ j.cursor }.to raise_error(Systemd::JournalError)
532
+ expect { j.cursor }.to raise_error(Systemd::JournalError)
452
533
  end
453
534
 
454
535
  end